JSP Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 1776 Page Views: 

What are the life-cycle methods of JSP?



Posted By: Avi Date: 17 September 2009 06:38:31 AM
 Answer:

JSP page is processed into a servlet class which implements the HttpJspPage interface of the javax.servlet.jsp package. The 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 these three interfaces. The JspPage interface declares two mehtods, jspInit() and jspDestroy(), while HttpJspPage interface declares one method _jspService(). So these three methods must be implemented by all the JSP pages and these are also the life-cycle methods of JSP page.

1)jspInit():
The container calls the jspInit() to initialize the servlet instance. It is called before any other method, and is called only once for a servlet instance. The jspInit() method can be overridden within a JSP page.

2)_jspService():
The container calls the _jspservice() for each request and it passes the request and the response objects. The _jspService() method cannot be overridden.

3) jspDestroy():
The container calls this when its instance is about to destroyed. The jspDestroy() method can be overridden within a JSP page.


Posted By: eTechPlanet


Date: 17 September 2009 06:38:31 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image 2ec6fW
Related Questions
JSP : What is deployment descriptor?

What is deployment descriptor?

A deployment descriptor is an XML based file which describes a web application's  deployment se....
Category: JSP Date: 11/3/2010 3:31:59 PM
JSP : What is Server side push?

What is Server side push?

It used to refresh a servlet and that happens when client first connects to Server, then Server keep....
Category: JSP Date: 11/3/2010 2:26:57 PM
JSP : What are the parameters for service method ?

What are the parameters for service method ?

ServletRequest and ServletResponse
Category: JSP Date: 11/3/2010 1:53:57 PM
JSP : What is URL Encoding and URL Decoding ?

What is URL Encoding and URL Decoding ?

URL encoding is the method of replacing all the spaces and other extra characters into their corresp....
Category: JSP Date: 11/3/2010 12:04:58 PM
JSP : Can we useĀ  ServletOutputStream object from a JSP page?

Can we useĀ  ServletOutputStream object from a JSP page?

No. 
Category: JSP Date: 11/3/2010 11:31:57 AM