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 )

The output of System.out.println(5<<2) in Java

Interview Question: What is EJB client JAR file?

Interview Question: How do I install Struts?

What is Collection API?

Interview Question: Can I invoke Runtime.gc() in an EJB?

Tell me something about J2EE component?

What do you understand by a container in J2EE?

What are types of J2EE clients?

What is the difference between JTS and JTA?

Question: How would you go about analyzing performance of an application?

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

Interview Question: What is abstract schema?

What are all the different scope values for the tag?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

What types of comments are available in the JSP?

Latest Articles (in Interview)