Life Cycle of JSP, JSP Lifecycle, What is the LifeCycle of JSP


Life Cycle of JSP, JSP Lifecycle, What is the LifeCycle of JSP

The JSP is defined the complete life cycle for compilation to destroying the Objects. It consist the four major stages, the every stage defined its special task for JSP engine.
These Stages are as follows:-


  1. Compilation
  2. Initialization
  3. Execution
  4. Garbage Collection

Compilation:- When a client request for a JSP page the JSP engine checks the page compile first time or its already compiled and also checks after the changes made in a JSP page, every time when the changes made into a web page the JSP engine compile it.

Initialization:- When a JSP compiled to the servlet class then the initialization process will begin and the jsp_init() method will be called, if you need to perform any specific task on initialization time you can override the jsp_init() method.

public void _jspInit()
{
//code here
}

Execution:- The actual work is done into this step,
It is stage where the HttpServletRequest and HttpServletResponse is handle and the all services is done like creating objects, making data connections, handling beans etc.

public void _jspService(HttpServletRequest request,HttpServletResponse response)
{
//code here
}

Garbage Collection:- When all operation has done and the container needs to destroy the unused objects and the _jspDestroy() method called.

public void _jspDestroy()
{
//handle garbage collection code here.
}


Thanks for visiting

{ 0 comments... read them below or add one }

Post a Comment