1 Answers
The Lifecycle of a JSP Page vs Servlet
In JSP, the lifecycle involves several phases:
- Translation phase: JSP page is translated into a servlet.
- Compilation phase: The servlet generated is compiled into a Java servlet class.
- Initialization phase: The servlet class is loaded and initialized.
- Execution phase: The JSP page is executed, generating the dynamic content.
- Destroy phase: The servlet is destroyed when the application or server shuts down.
On the other hand, the servlet lifecycle involves:
- Initialization: The servlet is loaded and its init() method is called.
- Request handling: The servlet processes client requests in its service() method.
- Destroy: The servlet is destroyed when the container decides to remove it.
While both JSP and servlets have initialization, execution, and destruction phases, the key difference lies in the translation and compilation phases that are unique to JSP pages.
Please login or Register to submit your answer