This tips explains the few points on how to use the load-on-startup element on the web.xml file. When erver is starting, it is possible to tell the container to load a servlet on the startup. You can load any number of servlets on the startup. Normally this is done for any initialization purpose. Look into the following example:
1 2 3 4 5
<servlet> <servlet-name>TestServlet</servlet-name> <servlet-class>TestServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
The above example tells the container that the servlet will be loaded at first.The <load-on-startup> sub-element indicates the order in which each servlet should be loaded. Lower positive values are loaded first. If the value is negative or unspecified, then the container can load the servlet at anytime during startup.