Google News
logo
Java Servlets - Interview Questions
Explain the Lifecycle of Servlet.
The life cycle of a servlet is explained with reference to the below diagram.
 
* At first, the Servlet class is loaded as per the request received from the Client.
* Then the new instance or object of a servlet is created. Only one object is created, for every life cycle.
* Then the Init () method, used to initialize the servlet is invoked.

Syntax : public void Init ()
 
* The Service () method is invoked every time when a new request is received to perform any operations.
Syntax : public void service ()
 
* Then the destroy method is invoked to perform the clean-up operation.
Syntax : destroy ()
Advertisement