Switch to full style
What's behind JSP & Servlets
Post a reply

Explain the life cycle methods of a Servlet.

Fri Nov 07, 2008 1:06 pm

Q: Explain the life cycle methods of a Servlet.

A: The javax.servlet.Servlet interface defines the three methods known as life-cycle method.
public void init(ServletConfig config) throws ServletException
public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException
public void destroy()
First the servlet is constructed, then initialized wih the init() method.
Any request from client are handled initially by the service() method before delegating to the doXxx() methods in the case of HttpServlet.

The servlet is removed from service, destroyed with the destroy() methid, then garbaged collected and finalized.



Post a reply
  Related Posts  to : Explain the life cycle methods of a Servlet.
 Explain the life-cycle mehtods in JSP     -  
 Game Of Life 3D     -  
 Please Explain Little Bit More!     -  
 Explain ServletContext.     -  
 explain event handling in java     -  
 Which methods is best for SEO?     -  
 What Are Constructor Methods?     -  
 methods in ActionListener interface     -  
 JSP Passing Arrays to Methods     -  
 Calling Overloaded Methods     -