JSP life cycle
The life cycle of JSP page internally implemented as a Servlet. These are the following stages through which a JSP page has to pass:
- Translation – This is an initial phase of JSP lifecycle that exist when first request of the JSP page is made. In this phase, web container translates the JSP page into servlet class.
- Compilation – As soon as the JSP page is translated, web container compiles the servlet class. Both translation and compilation have been proceeded only when JSP page’s servlet is older than JSP page.
- Loading and Instantiating – Once the translation and compilation have been done, JSP page servlet follows the Servlet lifecycle. Hence, class is loaded and instance is created.
- Execution – In this phase, the actual task is performed. Web container invokes jspInit() method to initialize servlet instance. To pass request and response objects, web container invokes jspService() method.
- Destruction – This is the final phase of lifecycle in which web container invokes jspDestroy() method to remove JSP page servlet, if it is no more further required.
Some key features of JSP technology are as follows:
- Portable – JSP is a platform independent technology. So, JSP web pages can run on any browser and web container independently.
- Simple– It provides an easy way to develop and deploy web applications.
- Powerful – JSP is a Java based technology. Thus, it is secured and robust.
- Tag based approach – Instead of heavy bug of java code, JSP uses simple pre-defined tags.
- Customized tag – JSP also allows users to define their own tag.