Thursday 19 January 2017

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().

_jspServeice() is wriiten by container and also in that method all the implicit objects will be created except request and response. If you override that method you can’t get those object.
Whatever we write inside the scriptlet gets converted into _jspService() method into the generated Servlet. So, to override this method, you can simply write the code in scriptlet. But, you cannot manually override this method. It will result in compilation failure.

No comments:

Post a Comment