Easy learning with example program codes

load-on-startup in web.xml


The load-on-startup is the sub attribute of servlet attribute in web.xml. It is used to control when the web server loads the servlet. As we discussed that servlet is loaded at the time of first request. In this case response time is increased for first request. If load-on-startup is specified for a servlet in web.xml then this servlet will be loaded when the server starts. So the response time will not increase for fist request.

Any positive or negative value can be passed in the load-on-startup. If positive value is passed then all servlets having load-on-startup sub attribute will be loaded when server starts but a servlet having low positive value will be loaded first. In case of negative value servlet will be loaded at the time of first request.

Sample code of load-on-startup in web.xml.

   //other attributes  
  	<servlet-class> </servlet-class>
  //other attributes

In the above example Servlet1 and Servlet2 will be loaded when server starts because positive value is passed in there load-on-startup. Servlet3 will be loaded at the time of first request because negative value is passed in there load-on-startup.
Next Topic: RequestDispacher interface with example.
Previous Topic: welcome-file-list in web.xml with example.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki