File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes question on servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "question on servlet" Watch "question on servlet" New topic

question on servlet

raghuram bikkani

Joined: Jan 18, 2006
Posts: 16
in ,<load-on-startup>3</load-on-startup> what is 3 indicates?
Umakanth Godavarthy
Ranch Hand

Joined: Nov 10, 2005
Posts: 37
From Servlet 2.4 spec
The element load-on-startup
indicates that this servlet should be loaded (instantiated and have its init() called) on
the startup of the Web application. The element content of this 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-startup value.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

It indicates that the servlet will be loaded on startup.
Moreover, the container will load the servlet in the order you set them in web.xml.
So a servlet with load-on-startup at 2 will be loaded BEFORE another one set to 3.

Beware that this number is not related to time.

[My Blog]
All roads lead to JavaRanch
Umakanth Godavarthy
Ranch Hand

Joined: Nov 10, 2005
Posts: 37
It indicates 3 instances of the servlet will get create on the loading of servlet

Dipali its wrong, it doesn't indicate the number of instances. Only one instance will be created unless it implements SingleThreadModel, in which case it depends on container how many instances will be created.
I agree. Here's the link:
subject: question on servlet
It's not a secret anymore!