File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes load on startup 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" Watch "load on startup" New topic

load on startup

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518

I need to start two servlets along with the server starts up.In my web.xml,i have configured like:

But the first program only gets started.How could i start two programs when the server starts.please assist me to solve this.

Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3902

But the first program only gets started.How could i start two programs when the server starts.

What you mean by "starting programs" ? "<load-on-startup>" make the server loads the servlet class at the server startup rather than waiting till the first request. If you mean the same, how you verifed that two servlets are not loaded?

[How to ask questions] [Twitter]
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
<servlet-class> this tag should contain class name with package.
If your Servlets are Voicebroadcast1, busy1 without package, then fine.

Check your servers log file, Is there any exception comming on server start up?

Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689

Hi preethi,

Actually <load-on-startup>1</load-on-startup> is use just load your servlet to load into container.

The basic of why this need is when your servlet complex and it takes time to load on container then you just load that servlet at start of your server.

basically the servlet get load into container when first user request for that servlet. so, if your servlet takes time to load when user request at that time you just load servlet.

Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
mike ickx

Joined: Apr 30, 2009
Posts: 9
Use a HttpContextListner instead, its the first event that will take place, and place your configuration in the contextInitialized() method. the events that you want to occur when closing the app, can be put in the contexDestroyed() method.
I agree. Here's the link:
subject: load on startup
It's not a secret anymore!