Hi Vikas,
Servlets are loaded and initialized at the first request come to the server and stay loaded until server shuts down. However there is another way you can initialized your servlet before any request come for that servlet by saying <load-on-startup>1</load-on-startup> in the deployment descriptor. You can specify <load-on-startup>1</load-on-startup> in between the <servlet></servlet> tag.
Permanent servlet: - Such types of servlet get instantiated on start of the server. The instance of this servlet remains on the server till the server runs. Whenever the server shutdowns then instance of this servlet gets destroyed and before to it destroy () method execute. Life span of servlet is same as the life span of the server. Such type of servlet is independent of users appearance. If any user come to access this servlet then doGet(),doPost() or service() method executes. Such types of servlets can be used to perform task on start of server or on stop of server. The servlet can be created by using generic or http servlet. During deployment of this servlet a tag must be used as <load-on-startup>
Web.xml settings
<servlet>
<servlet-name>The name of servlet</servlet-name>
<servlet-class>The class of servlet</servlet-class>
<load-on-startup>This contains a number of specifying order of execution between permanent servlet</load-on-startup>
</servlet>
<servlet>
Thanks