Programming Tutorials

Question: Explain the life-cycle methods in JSP?

By: Guru Singh in Interview Tutorials on 2008-08-24  

Question: Explain the life-cycle methods in JSP?

Answer:  The generated servlet class for a JSP page 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 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.

 

 

 

 





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Interview )

Interview Question: What is abstract schema?

Interview Question: How is the MVC design pattern used in Struts framework?

What are implicit Objects available to the JSP Page?

Explain the new Features of JDBC 2.0 Core API?

What is Collection API?

Question: Explain the life-cycle methods in JSP?

Question: What is a Hidden Comment in JSP?

Types of Interviews

Interview Question: Is Decorator an EJB design pattern?

Interview Question: What is Remote client view?

Interview Question: What is EJB client JAR file?

Interview Question: If the framework doesn't do what I want, can I request that a feature be added?

Interview Question: Why aren't the Struts tags maintained as part of the Jakarta Taglibs project ?

Interview Question: Does Struts include its own unit tests?

Interview Question: Do you have to credit Struts on your own website?

Latest Articles (in Interview)