GeeCON Prague 2014*
The moose likes Servlets and the fly likes load-on-startup in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "load-on-startup in web.xml" Watch "load-on-startup in web.xml" New topic
Author

load-on-startup in web.xml

tmsenthil kumar
Greenhorn

Joined: Aug 10, 2004
Posts: 11
Can any one tell me what is the purpose of <load-on-startup> in web.xml
Richard Bradford
Ranch Hand

Joined: Apr 20, 2004
Posts: 48
It tells the web container to load the servlet when the container starts up.
Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
As there are two ways when a servlet instance can be created.
1. Creating Servlet instances on Server Startup
2. Creating servlet class instance on the first request by Client.

So Load on starup tells to create instances on server startup - Loadtime.

Hope u are clear now.

Thanks,
Rahul Juneja
rahulj2k3@yahoo.com


Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
John Mallavalli
Ranch Hand

Joined: Apr 24, 2002
Posts: 46
The load-on-startup element indicates that a servlet should be loaded on the startup of the web application. This element can take an integer value which indicates the order in which the servlet should be loaded.

If the value is negative, or if this element is not present, the container is at its will as to when it should load the servlet. If the value is a positive integer or 0, the container must load and initialize the servlet when the application is deployed.

Generally the 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.

Hope this helps.
Thanks,
John


Do not let what you cannot do interfere with what you can do !!<br /> <br />SCJP & SCWCD 1.4
tmsenthil kumar
Greenhorn

Joined: Aug 10, 2004
Posts: 11
i am clear now.
ok. iam using load-on-startup for a servlet the instance of the servlet will load when the server startup.
i want to display my own first page when the server startup.
can i use load-on-startup or any other alternate way.
Pls any one tell me.
John Mallavalli
Ranch Hand

Joined: Apr 24, 2002
Posts: 46
To display your own page, load-on-startup element cannot help you. You need to use the element "welcome-file-list" in which you can specify, as below, so that the server automatically serves you the page specified when the request comes for your webapp without speicifying the exact resource:
<welcome-file-list>
<welcome-file>my-own-page.html</welcome-file>
</welcome-file-list>

So when the url "www.my-site.com/my-web-app" hits the server then the default page "my-own-page.html" gets served.

Hope this helps.
- John
tmsenthil kumar
Greenhorn

Joined: Aug 10, 2004
Posts: 11
Thank u.
 
GeeCON Prague 2014
 
subject: load-on-startup in web.xml