Information About Servlet Interface and life cycle Methods in Java.

This resource contain the information about life cycle methods of Servlet Interface.

Servlet Interface

This interface contains the life cycle methods for a servlet page
Following are the life cycle methods of Servlet Interface :-

1. Public void init (ServletConfig config) throw ServletException
This method is the first method to be executed in life cycle of the Servlet page. The method contains an object parameter of ServletConfig interface pack. The ServletConfig object holds information of Servlet container and other parameter objects.

2. Public void service (ServletRequest req, ServletResponse res) throws servletException, IOException
This method is executed after the init method. This method is used to retrieve data send by the client, process the data and access the machine resource and their after respond output back to the client who made the request.
This method contains two object parameters of ServletRequest and ServletResponse interface type. This method automatically instantiates this parameter object. This client data and information is retrieve through ServletResponse object. This method throws ServletException and IOException.

3. Public void destroy()
This method is called when the Servlet page is unloaded or destroyed by the servlet container.

View for more information about Servlet Servlet in Java


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: