Yes one can override JSP init and destroy method but can’t override the _jspService method of JSP
Generally in the init method some initialization will be done and in the overridden destroy method, finalize operations are performed.
Both the methods can be easily override inside a declaration in a JSP as shown below:
<%! public void jspInit() { //Write code to create database connections. } %> <%! public void jspDestroy() { //Write code to close database connections. } %>What is the need to override these methods?
1) jspInit() can be useful for allocating resources like database connections, network connections, and so forth for the JSP page.
2) jspDestroy() method is override to close the connections created in step 1
No comments:
Post a Comment