JSP Compilation:
When a request comes for a JSP, the JSP engine first checks whether it needs to compile the page. If the page has never been compiled, or if the JSP has been modified since it was last compiled, the JSP engine compiles the page.
JSP compilation involves three steps:
1) Parsing the JSP.
2) Converting JSP to a servlet.
3) Compiling the servlet.
1) Initialize – jspInit()
After compiling and loading the JSP page it invokes the jspInit() method before servicing any requests. You can override the jspInit() method if there is any specific need for initializing your JSP.
public void jspInit(){
// Your Initialization code here.
}
2) service – jspService()
This is the next step after initialization of JSP . The _jspService() method takes HttpServletRequest and HttpServletResponse as its parameters as follows:
void _jspService(HttpServletRequest request, HttpServletResponse response) {
// Your code for handling service
}
3) Complete – jspDestroy()
The jspDestroy() method is the JSP equivalent of the destroy method for servlets. You can Override jspDestroy if you need to perform any cleanup, such as releasing database connections.
public void jspDestroy(){
// Your cleanup code goes here.
}
Jenise Steininger says
May 29, 2011 at 10:26 pmWow this is a great resource.. I’m enjoying it.. good article