This interface defines the following two life cycle methods.
2. jspDestroy():
Syntax: public void jspDestroy()
We can’t override destroy() method directly in the JSP.Because it is declared as the final in HttpJspBase class.
1. jspInit()
2. jspDestroy()
1.jspInit() :
syntax :
public void jspInit() |
This method will be executed only once at the time of first request to perform initialization activities.Web container always calls init(ServletConfig config)present in HttpJspBase class which intern calls jspInit() method present in our JSP .
Test.jsp:
<%! public void jspInit() { System.out.println (“my own initialization activities”); } %> |
We can’t override init(ServletConfig config) in our JSP, because it is declared as final in parent class (HttpJspBase).Init() method syntax in HttpJspBase class
public final void init(javax.servlet.ServletConfig config)throws javax.servlet.ServlerException |
HttpJspBase:
<%! public final void init(serveletconfig config) { System.out.println (“my own initialization activities”)’ } %> |
Cannot override the final method from HttpJspBase.
2. jspDestroy():
Syntax: public void jspDestroy()
This method will be executed only once to perform cleanup activities just before taking JSP from out of service.
Web container always calls destroy() method present in HttpJspBase class which intern calls JspDestroy().
Test.jsp:
<%! public void destroy() { // put custom code for cleanup operations } %> |
Test.jsp
<%! public void destroy( ) { System.out.println(“my own clean up operations”); } %> |
C.E: cannot override the final method from HttpJspBase.
No comments:
Post a Comment