This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Servlets and the fly likes sinificance of  value of tag  <load-on-startup> in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "sinificance of  value of tag  <load-on-startup> in web.xml" Watch "sinificance of  value of tag  <load-on-startup> in web.xml" New topic
Author

sinificance of value of tag <load-on-startup> in web.xml

Anwar Hussain
Ranch Hand

Joined: Jul 24, 2009
Posts: 35
Hi,

Please explain the significance of the value we will give for the tag <load-on-startup> in web.xml file.

Ex :

In the above tag what the value 5 indicates ???
What if I give 3 instead of 5.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
It means that if you have another servlet with a value for <load-on-startup> that is less than this one, it will get loaded before this servlet.

A positive value means that it WILL get loaded upon server startup (I think 0 too, not 100% sure though)


JDBCSupport - An easy to use, light-weight JDBC framework -
Anwar Hussain
Ranch Hand

Joined: Jul 24, 2009
Posts: 35
Sebastian Janisch wrote:It means that if you have another servlet with a value for <load-on-startup> that is less than this one, it will get loaded before this servlet.

A positive value means that it WILL get loaded upon server startup (I think 0 too, not 100% sure though)



hi,
you mean to say it is the priority value for creation of that servlet object???
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
If you omit this tag, the container might load the servlet at any arbitrary point during runtime. It might be during startup, but could also be upon first client request (which is bad if there are heavy resources to be loaded upon creation). If you pass any positive value to it, it will get loaded upon startup. The figure simple determines the order in correlation to the other servlets.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56545
    
  14

The Servlet Specification describes this in detail.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 219
you can find the exact explanation at the below link

http://www.javabeat.net/tips/166-load-on-startup-element-in-webxml.html


Regards
Salil Verma
jazy smith
Ranch Hand

Joined: Nov 18, 2009
Posts: 101
Sebastian Janisch wrote:If you omit this tag, the container might load the servlet at any arbitrary point during runtime.


hi,

can you please explain what is the difference between loading of servlet and actuall display of the servlet on the monitor screen. I mean when you say the servlet is loaded, what does that mean actually ?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56545
    
  14

It means that the servlet class definition is loaded, an instance of the servlet is created, and the init() method called.
jazy smith
Ranch Hand

Joined: Nov 18, 2009
Posts: 101
thanks bear.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: sinificance of value of tag <load-on-startup> in web.xml
 
Similar Threads
Startup class in WAS
<load-on-startup> doubt
What's the purpose of load-on-startup tag in web.xml?
Is it guaranteed that web server will initialize all web application on the server startup time
Struts