Friday 5 July 2013

JSP LifeCycle

// siddhu vydyabhushana // 1 comment
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
- See more at: http://www.java2all.com/1/2/4/90/Technology/JSP/JSP-introduction/JSP-life-cycle#sthash.pJXGQLE9.dpuf

1 comment: