Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Anwar Hussain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Anwar Hussain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Servlet Specification describes this in detail.
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can find the exact explanation at the below link

http://www.javabeat.net/tips/166-load-on-startup-element-in-webxml.html
 
jazy smith
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks bear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic