• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

load-on-startup

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
pls help me in understanding servlet basics---
1)if two servlets has the same value for load-on-startup what happens?
2)if I give negative value for load-on-startup , what does it mean?
thanx in advance
regards
devayani
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<load-on-startup> : WebLogic Server initializes this servlet when WebLogic Server starts up. The content of this element must be a positive integer indicating the order in which the servlet should be loaded. Lower integers are loaded before higher integers. If no value is specified, or if the value specified is not a positive integer, WebLogic Server can load the servlet in any order in the startup sequence.



I think, if two servlets have the same value for <load-on-startup> then any of the servlet can be loaded first.

And for the second question, I think you can get from the above quote....

Thanks,
Lalitha.
 
devayani Devasthali
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first of all thanx for the reply,
actually i am using tomcat 5
when I tried the value "-1" for load-on-startup, it doesnt get loaded with server loading.
when I called that servlet , then its loaded.. so I got confused? could u pls explain this to me?

Also would like to know- cant we specify load-on-startup for every servlet?anyway I have written servlets means I am going to call them in my application. So to save time for instanciation and loading of servlet after it is requested can we do that at the time of loading of server itself?

thanx in advance
regards
Devayani
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Devayani,
Definitely you can specify <load-on-startup> for each servlet but you will write it for the servlets which you need to initialize at server startup.
e.g. If you use <load-on-startup> for each servlet then, if server supports instance pooling (which most web servers use ,i suppose) lot many instances will be created in a server memory even if you are not using them...i hope this is clear... so writing <load-on-startup> for each servlet is not a very good idea normally (Although practically this is possible)
You will definitely use this for a Servlet like ActionServlet in Struts Framework (if you are not aware of the Struts then just go through some basic part of it)since its a main controller in Struts Framework & needs to be initialized before any request hits the server

Shrinivas
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shrinivas Mujumdar:

If you use <load-on-startup> for each servlet then, if server supports instance pooling (which most web servers use ,i suppose) lot many instances will be created in a server memory even if you are not using them...



Not entirely true..
Unless your servlets implement SingleThreadedModel, they won't be pooled (there will only be on instance of each servlet per container).
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is from the servlet spec:



In other words the behaviour will be container specific and not guaranteed to work the same way across different versions of any particular container.

In light of this, there is no good reason to use negative numbers for this value.
 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just curious, why do we ever want to put in a negative number?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Alec Lee:
Just curious, why do we ever want to put in a negative number?



If I had to guess, I would say to put a new servlet at the top of the list without having to reorder all of the others.
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Not entirely true..
Unless your servlets implement SingleThreadedModel, they won't be pooled (there will only be on instance of each servlet per container).


ya I do agree.....but
SingleThreadModel interface is Deprecated Ben..in servlet 2.4 Spec. so why to talk about the stuff which is not recommended.......


Shrinivas
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shrinivas Mujumdar:

ya I do agree.....but
SingleThreadModel interface is Deprecated Ben..in servlet 2.4 Spec. so why to talk about the stuff which is not recommended.......

Shrinivas



First, I was not recommending it.
Second, since most of a developer's time is spent maintaining existing code it is important that we understand all of the API for the tools we are using; including the deprecated aspects of it.

My main point is that pooling is a non-issue except for SingleThreadedModel.
Using load-on-startup will not cause more instances of a given servlet to exist than not using it (unless of course nobody ever hits it, in which case it would never be loaded at all without load-on-startup).
reply
    Bookmark Topic Watch Topic
  • New Topic