<load-on-startup> Element

Load on startup is a element to configure a web.xml to generate a set of servlet object to be sent during the startup of server or application is deployed on server. You can also call it initialization of Servlet. Following element needs to integer value to configure.


Merits of load-on-startup element

Servlet loads on very first request and it is clear that it utliize more time at first request. To specify the load-on-startup in web.xml, servlet should be loaded on the start of project deployment or server launch and it will save lots of time for generating response.

Passing positive value

In case of passing positive values, the lower integer value will automatically loaded instead of higher integer value servlet. In simple words, container will download the servlet in counting integer value like 0 and then 1,2,3. This will change the load time so passing positive value will have impact on container loading.

Take a look at example given below :-]




We define 2 Servlets and they will be loaded at launch of server or project deployment. Servlet 1 and then Servlet 2 will be loaded.

Passing negative value

Incase of negative configured value then loading container will ingnore the servlet and will load first request to load and will create a object of a servlet but a container will not throw exceptions.