Java2all.com  

JSP life cycle





Share This Topic -

JSP Life Cycle:

The lifecycle of JSP is controlled by three methods which are automatically called when a JSP is requested and when the JSP terminates normally.

These are:

jspInit () , _jspService() , jspDestroy().

jspInit() method is identical to the init() method in a Java Servlet and in applet.

It is called first when the JSP is requested and is used to initialize objects and variables that are used throughout the life of the JSP.

_jspService() method is automatically called and retrieves a connection to HTTP.

It will call doGet or doPost() method of servlet created.

jspDestroy() method is identical to the destroy() method in Servlet.

The destroy() method is automatically called when the JSP terminates normally.

It isn’t called by JSP when it terminates abruptly.

It is used for cleanup where resources used during the execution of the JSP ate released, such as disconnecting form database.

Java2All.Com