What JSP lifecycle methods can I override?

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() {. . .}%>

Showing Answers 1 - 13 of 13 Answers

ravi_1229

  • Feb 18th, 2010
 

Any code written in jsp with in <%... %> tag is placed by the container into jspService() method. Anyhow we can override jspInit() and jspDestry() using <!%...%>. but we cannot override jspService() method in jsp. 

  Was this answer useful?  Yes

Lakshmi

  • Aug 29th, 2012
 

init() and destroy() methods can be overrided by an JSP page author

  Was this answer useful?  Yes

trinadh Subrahmanyam Nune

  • Aug 10th, 2016
 

The overriding of JSPINIT method is useful as we are getting the intialization for connections and not the destroy....As after execution of JSP it automatically dies

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions