• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

load-on-startup

 
Andrew Rigsby
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've read that the <load-on-startup> element allows you to specify that a servlet is loaded at deployment time if it defines a value greater than 0. However, I've also read that it allows you to specify the order of servlet loading.

What I wanted to know was that if one servlet has a <load-on-startup> value of 0 and another servlet has a value of 1, which is loaded first?

I assumed it would be the servlet with the lower value, i.e. 0, but when I try it out in Tomcat the servlet with the <load-on-startup> of 1 loads first?

Thanks!!
 
Tim Puchala
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've answered the question in your question.
You said load on deployment is enabled by a value greater than 0. What does 0>0 evaluate to?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said load on deployment is enabled by a value greater than 0

This is not true. This was actually true in older version, but not anymore.

The 2.4 version specifies that :
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.



Check your version of web.xml.
If you use 2.4, the servlet with a load-on-startup value of 0 should be initialized first.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 2.4 version specifies that :


satou, nice to see that you co relate every post to the spec !
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nice to see that you co relate every post to the spec

My policy is "Always rely on what the spec says, not on what your web container does"
 
Andrew Rigsby
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

I've checked the version of my web.xml and it specifies 2.4. Tomcat still continues to load the servlet with a <load-on-startup> of 1 before the servlet with a <load-on-startup> of 0.
 
Krishna Srinivasan
Ranch Hand
Posts: 1876
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check whether you have the foloowing schemea in web.xml

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">

for me its loaded when the value is 0
 
Andrew Rigsby
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that's more or less what I have:

<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

I'm using Tomcat 5.5.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic