• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need an answer...

 
trupti nigam
Ranch Hand
Posts: 627
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which statements are correct about load-on-startup elements
1) It must be an integer
2) It can be negative
3) If it is 0 (zero) it will be loaded at deployment time
4) Serveral servlets can have the same value for this element
I think the correct answer is..1,3
thanks
Trupti
 
Jagdeep Singh
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All options are corrrect.
* The container may choose the order of loading of servlets with the same load-on-startup value. *If the value is 0 or +ive then the container must load & initilaize the servlets as app depolyed in the ascending order of load-on-startup value.
* Or if it is -ive or this element is not present, then container is free to load servlets whenever it choose.
 
Maha Annadurai
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, note that just the mere presence of <load-on-startup> </load-on-startup> element without a value will cause the servlet to be loaded on startup.
In my work place, there was a servlet which was configured with a <load-on-startup> value of 1 initially. At one point of time we did not want that servlet to be loaded on startup. What the deployer did was, he just erased the value alone (thinking that it will not be loaded on startup).
Latter we found that the servlet was still loading on JRun restart. This is how we learned that if you do not want a servlet to be loaded on start up, just delete the whole segment of <load-on-startup> n </load-on-startup>.
Regards,
Maha Anna
 
k space
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take a look at the spec about <load-on-startup>.
The load-on-startup element indicates that this servlet should 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 should 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.
Back to the question, all options are correct.
 
Bernd Stransky
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP spec does not specifiy what the container will do if the <load-on-startup> element is present, but without any contents. According to Maha, it seems it treats like a 0.
-Bernd
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic