Hello Everyone, I want to know about the lifecycle phases of JSP. I am preparing for the JSP interview which is in the upcoming week. Can anyone explain me the process of Translation, ClassLoading, and Initialization with some examples?
Hello Everyone, I want to know about the lifecycle phases of JSP. I am preparing for the JSP interview which is in the upcoming week. Can anyone explain me the process of Translation, ClassLoading, and Initialization with some examples?
Hi Arjun,
Here you can go to know more about the lifecycle phases of JSP.
- 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)
Here you can know each step in details also:
Translation of JSP page to Servlet :
This is the first step of JSP life cycle. This translation phase deals with Syntactic correctness of JSP. Here test.jsp file is transllated 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 JSP source is now loaded into container.
Instantiation :
Here instance of the class is generated. The container manages one or more instance by providing response 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 object as parameters.This method cannot be overridden.
JSP Cleanup :
In order to remove the JSP from use by the container or to destroy 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.
To check here more JSP interview Questions for upcoming JSP interviews.
Similar Threads |
|