DEVFYI - Developer Resource - FYI

When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

Servlet Interview Questions and Answers


(Continued from previous question...)

22. When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

An instance of servlet is created when the servlet is loaded for the first time in the container. Init() method is used to configure this servlet instance. This method is called only once in the life time of a servlet, hence it makes sense to write all those configuration details about a servlet which are required for the whole life of a servlet in this method.

(Continued on next question...)

Other Interview Questions