0% found this document useful (0 votes)
296 views2 pages

Life Cycle of JSP

The JSP life cycle involves 6 steps: 1. Translation of the JSP page to a servlet class file. 2. Compilation of the JSP page into a .java file that is then compiled into a .class file. 3. Classloading of the servlet class file into the container. 4. Instantiation of an instance of the servlet class. 5. Initialization by calling the jspInit() method on the servlet instance. 6. Request processing by calling the _jspService() method to handle requests.

Uploaded by

Aman khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
296 views2 pages

Life Cycle of JSP

The JSP life cycle involves 6 steps: 1. Translation of the JSP page to a servlet class file. 2. Compilation of the JSP page into a .java file that is then compiled into a .class file. 3. Classloading of the servlet class file into the container. 4. Instantiation of an instance of the servlet class. 5. Initialization by calling the jspInit() method on the servlet instance. 6. Request processing by calling the _jspService() method to handle requests.

Uploaded by

Aman khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Life cycle of JSP

A Java Server Page life cycle is defined as the process that started with its creation
which later translated to a servlet and afterward servlet lifecycle comes into play. This
is how the process goes on until its destruction.

Following steps are involved in the JSP life cycle:


Translation of JSP page to Servlet
 Compilation of JSP page(Compilation of JSP into test.java)
 Classloading (test.java to test.class)
 Instantiation(Object of the generated Servlet is created)
 Initialization(jspInit() method is invoked by the container)
 Request processing(_jspService()is invoked by the container)
 JSP Cleanup (jspDestroy() method is invoked by the container)

We can override jspInit(), jspDestroy() but we can’t override _jspService() method.

Translation of JSP page to Servlet :


This is the first step of the JSP life cycle. This translation phase deals with the
Syntactic correctness of JSP. Here test.jsp file is translated to test.java.
Compilation of JSP page :
Here the generated java servlet file (test.java) is compiled to a class file (test.class).
Classloading :

Servlet class which has been loaded from the JSP source is now loaded into the
container.
Instantiation :
Here an instance of the class is generated. The container manages one or more
instances by providing responses to requests.
Initialization :
jspInit() method is called only once during the life cycle immediately after the
generation of Servlet instance from JSP.
Request processing :
_jspService() method is used to serve the raised requests by JSP. It takes request and
response objects as parameters. This method cannot be overridden.
JSP Cleanup :
In order to remove the JSP from the use by the container or to destroy the method for
servlets jspDestroy()method is used. This method is called once, if you need to
perform any cleanup task like closing open files, releasing database connections
jspDestroy() can be overridden.

You might also like