Monday, June 22, 2009

life cycles

servlet:

web/servlet container loads a servlet
|
Webcontainer creates an instance
|
Initializes the servlet instance by calling init()
|
Invokes service() passing request and response objects
|
webcontainer removes the servlet by calling destroy()

JSP:

When a request is mapped to a JSP page, the web container first checks whether the JSP page’s servlet is older than the JSP page. If the servlet is older, the web container translates the JSP page into a servlet class and compiles the class. Transalated JSP is saved as jspName_jsp.java. After the page has been translated and compiled, the JSP page’s servlet mostly follows the servlet life cycle

Container loads the JSP page’s servlet class
|
Creates an instance of the servlet class
|
Initializes the servlet instance by calling the jspInit method
|
Invokes the _jspService method for passing request and response objects
|
Removes the JSP page’s servlet by calling the jspDestroy method