|
Answer» The below IMAGE describes the different phases of the servlet lifecycle: There are five phases, are as follows: - Classloading phase: The first step is to LOAD the servlet class file (.class EXTENSION) by the web container.
- Instantiation phase: Next step is to instantiate the servlet by calling the default constructor.
- Initialize phase: In this phase, the init() method of the servlet is run where the servlet configuration will be assigned to the servlet. This is a lifecycle method provided by the Servlet interface which is run only once in the servlet lifetime.
- Request Handling phase: Here, the servlets provide services to different requests by making use of the service() method of the Servlet interface.
- Removal phase: In this phase, the destroy() lifecycle method of the Servlet interface will be called that is used for CLEARING the configuration and closing resources before servlet destruction. Post this, the garbage collection will TAKE place.
|