Reproduced in: http://www.blogjava.net/xzclog/archive/2011/09/29/359789.html
The following section of configuration makes it easier to get familiar with the Web:
<servlet> <servlet-name>CreateFxbgDir</servlet-name> <servlet-class>cn.gwssi.csdb.sys.common.CreateFxbgDir</servlet-class> <load-on-startup>0</load-on-startup> </servlet>
For example, if the value of <load-on-startup> 0 indicates loading the servlet and initializing the class, the init method of the class is called. in this method, you can write some information about the attribute file or the configuration file.
We noticed that this configuration contains: <load-on-startup> 1 </load-on-startup>. What is the role of this configuration?
The original English explanation is as follows: servlet specification: the load-on-startup element indicates that this servlet shocould 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 shocould 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 indicates whether the container loads the servlet at startup (instantiate and call its Init () method ).
2) its value must be an integer, indicating the order in which the servlet should be loaded.
2) When the value is 0 or greater than 0, it indicates that the servlet is loaded and initialized when the application is started;
3) if the value is smaller than 0 or is not specified, the container is loaded only when the servlet is selected.
4) The smaller the positive value, the higher the servlet priority, the more loaded the application is at startup.
5) when the values are the same, the container selects the order for loading.
Therefore, the values of X in <load-on-startup> x </load-on-startup>, 1, 2, 4, and 5 represent the priority rather than the start delay time.
The following questions:
2. Definitions not included in Web. XML (Multiple choices)
A. Default start page
B. Definition of servlet startup latency
C. error handling page
D. Re-load the JSP file after modification
Answer: B, d
Most servlets are created and initialized by the application server during the first request, but <load-on-startup> n </load-on-startup> can be used to change this situation, change the loading priority as needed!