Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<load-on-startup> in Deployment Descriptor

 
Lee Kian Giap
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some doubt on <load-on-startup> element

with the following situation:

1) the value is positive integer
the servlet will be loaded on startup, and the smaller the value the earlier that servlet starts (This one understood !)

2) few servlet's <load-on-startup> have same positive integer
Doubt and Confuse ??? (a) or (b) which one is correct
(a) the Container loads these servlets in the order in which they are declared in the DD
OR
(b) the Container choose the order of loading those servlets not following the order they declared in the DD

3) the value is negative integer
Doubt ???
Container will load whenever it want to load the servlet ? means the servlet will not be loaded on startup ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2) few servlet's <load-on-startup> have same positive integer

The container may choose the order of loading of servlets with the same load-on-start-up value. So it may be (a), or it may be (b).

3) the value is negative integer

If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. The servlet container is responsible for loading and instantiating servlets. The loading and instantiation can occur when the container is started, or delayed until the container determines the servlet is needed to service a request. So the servlet might be instanciated at startup, even without a load-on-startup tag, but that's not a guarantee.
 
Lee Kian Giap
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now understand the <load-on-startup> element.

Thank you !
 
Abdul Rahman
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lee,

I've few observations to share.

The value of the <load-on-startup> determines the order of loading the servlets by the container. The lesser the value the earlier it starts.

-->If the value is one(1), such servlets has the highest priority of loading the servlet by the container.
-->If the value is zero (0), this has got the least priority and this servlet will be the last to be loaded during the container startup .
-->If two or more servlets have the same value, the servlets in my case (tomcat 5), loaded in the reverse order of declaration in the web.xml.
To simplify, Consider that my web.xml declares 3 servlets with load-on-startup value as 4 in the below order:
ServletA
ServletB
ServletC
The order in which the servlets were loaded in my tomcat5 was ServletC, ServletB, ServletA.
-->If the value of the startup is negative, or the web.xml doesnot mention this element, then the container decides when to load this servlet.

The container will however load such servlets whenever a request comes in.

Hope this clarifies your doubts and confusions
 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 596, chapter 11 in first edition.
"container loads servlets with same load-onstartup value in the order in which they are declared in DD."
if servlets loading is different for each container, is above sentence wrong?
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vani venkat wrote:Page 596, chapter 11 in first edition.
"container loads servlets with same load-onstartup value in the order in which they are declared in DD."
if servlets loading is different for each container, is above sentence wrong?


This is from servlet spec 2.4, which might clear your doubt.

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.
 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks vijitha.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't it already listed in the errata ?

errata wrote:[596] 2rd & 3rd paragraph;
Whenever the book says "value greater than zero" should read "non-negative value".
This occurs in paragraph 2 and 3.
Also, the last sentence in paragraph 3 should read:
"If you have two or more servlets with the same value, the Container may
choose the order in which this subset is initialized."

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic