Friday, March 13, 2009

What JSP lifecycle methods can I override (JSP)

Question :What JSP lifecycle methods can I override? (JSP)
Answer :You cannot override the _jspService() method within a JSP page. You can
however, override the jspInit() and jspDestroy() methods within a JSP
page. jspInit() can be useful for allocating resources like database
connections, network connections, and so forth for the JSP page. It is good
programming practice to free any allocated resources within jspDestroy().
The jspInit() and jspDestroy() methods are each executed just once during
the lifecycle of a JSP page and are typically declared as JSP declarations:
<%!
public void jspInit() {
. . .
}
%>
<%!
public void jspDestroy() {
. . .
}
%>

No comments: