Understanding web.xml of Web project

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
		 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" 
		<servlet-name>project A</servlet-name>
		<servlet-name>project A</servlet-name>



The original English version of load-on-start is explained as follows:

Servlet specification:

The load-on-startup element indicates that this servlet should be loaded (instantiated and have its init() called) on the startup of the web application. The optional contents of these element must be an integer indicating the order in which the servlet should be loaded. If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. If the value is a positive integer or 0, the container must load and initialize the servlet as the application is deployed. The container must guarantee that servlets marked with lower integers are loaded before servlets marked with higher integers. The container may choose the order of loading of servlets with the same load-on-start-up value.


The load-on-startup element marks whether the container loads the servlet (instantiates and calls its init() method) at startup.

  • Its value must be an integer indicating the order in which the servlet should be loaded
  • When the value is 0 or greater than 0, it means that the container loads and initializes the servlet when the application starts.
  • When the value is less than 0 or is not specified, it means that the container will not load until the servlet is selected.

The smaller the positive value, the higher the priority of the servlet, and the earlier the application is loaded at startup.

When the values are the same, the container will load in its own order.


Tags: xml Java JavaEE encoding

Posted on Fri, 11 Oct 2019 13:13:10 -0700 by dc_jt