Monday, January 24, 2011

JSP lifecycle

JSP pages are basically the extension of servlet at a higher level. JSP enables the developers to create dynamic webpages and use java language to build html pages. When JSPs are compiled, they are actually compiled to be servlets. This is done by JSP engine. The servlet that is compiled for a particular JSP is used to service all the incoming requests from the page and generate responses.
javax.servlet.jsp package uses two interfaces for this purpose, namely
  • JSPPage
  • HttpJspPage
The above mentioned interfaces have three methods to control the life cycle of the JSP page. These are:
  • jspInit()
  • jspDestroy()
  • _jspService(HttpServletRequest request,HttpServletResponse response)
      

These methods are already present in the compiled servlet of the JSP. You can define jspInit()(to initialize) and jspDestroy()(to destroy) method, but the _jspService(HttpServletRequest request,HttpServletResponse response)(for handling requests and generating responses) method is automatically generated by the JSP engine.

No comments:

Post a Comment

Please comment, if you like the post, you find any mistake or if you have any query.