Meaningless Drivel is fun!*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "load-on-startup" Watch "load-on-startup" New topic
Author

load-on-startup

Nitin Dubey
Ranch Hand

Joined: Oct 30, 2000
Posts: 126

Hello,

What happend when we say load-on-startup for a servlet. I understand that the servlet is loaded at the startup. But..

Startup of Server ?
First hit for the Context ?
Is it guranteed ?
Which method is called when the servlet is loaded into memory ?

I basically want a servlet like StartupManager that will do all the startup activity.

Replies welcome,


Nitin Dubey
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi

The container initializes the servlet when the server starts. I think, this is the description for load-on-startup

bye for now
sat
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Startup of Server ?
First hit for the Context ?
Is it guranteed ?
Which method is called when the servlet is loaded into memory ?

Its loaded when the webapp containing the Servlet is deployed. Generally this will be when the server starts - but not always depending on how your server is configured. Yes, it is guarenteed. And its the init() method which is called: as is always the case for a first request for a Servlet. Be aware when writing a startup service that there is no guarentee in the spec. for the order webapps can be deployed - s oif the service applies to more than one webapp, you will have to look to a server specific route.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Also, if you are using Servlet Speck 2.3 or greater, you can use a contex listener for application initialization.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
 
subject: load-on-startup