Hi I like to know is there any other way servlet instance get created. One way is when client makes a first request to the servlet.
Thanks
Hi I like to know is there any other way servlet instance get created. One way is when client makes a first request to the servlet.
Thanks
You can specify servlet creation/running on startup of the container.
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
specifies a startup order. The above specifies that TestServlet
will start on container startup, and be the first (hence 1
).
I often prefer servlets starting during container startup. It allows them to perform any time-consuming initialisation prior to client interaction.
EDIT: As Skaffman pointed out below, 0
means start on first request.