• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

load-on-startup in web.xml

 
tmsenthil kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one tell me what is the purpose of <load-on-startup> in web.xml
 
Richard Bradford
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It tells the web container to load the servlet when the container starts up.
 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
John Mallavalli
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
tmsenthil kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic