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

Explain the life-cycle mehtods in JSP

Fri Nov 07, 2008 12:51 pm

Q: Explain the life-cycle mehtods in JSP?


A: THe generated servlet class for a JSP page implements the HttpJspPage interface of the javax.servlet.jsp package. Hte HttpJspPage interface extends the JspPage interface which inturn extends the Servlet interface of the javax.servlet package. the generated servlet class thus implements all the methods of the these three interfaces. The JspPage interface declares only two mehtods - jspInit() and jspDestroy() that must be implemented by all JSP pages regardless of the client-server protocol. However the JSP specification has provided the HttpJspPage interfaec specifically for the JSp pages serving HTTP requests. This interface declares one method _jspService().
The jspInit()- The container calls the jspInit() to initialize te servlet instance.It is called before any other method, and is called only once for a servlet instance.
The _jspservice()- The container calls the _jspservice() for each request, passing it the request and the response objects.
The jspDestroy()- The container calls this when it decides take the instance out of service. It is the last method called n the servlet instance.



Post a reply
  Related Posts  to : Explain the life-cycle mehtods in JSP
 Explain the life cycle methods of a Servlet.     -  
 Game Of Life 3D     -  
 Please Explain Little Bit More!     -  
 Explain ServletContext.     -  
 explain event handling in java     -