tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig mcclanahan <Craig.McClana...@eng.sun.com>
Subject Re: creation of application wide objects
Date Thu, 21 Dec 2000 00:56:00 GMT
Peter Brandt-Erichsen wrote:
> 
> My apologies for the confusion and also for
> misquoting David and you.
> 
> So, it is possible to specify a set of servlets
> to load on startup. That's awesome.
> 
> How do I point Tomcat to auto load servlets on
> start up, that are defined in my custom contexts?
> Does Tomcat scan through each defined context's
> web.xml and just start loading all the servlets that are
> defined?
> 

Yes.  When Tomcat first starts up, it reads the WEB-INF/web.xml file for
each app, and uses those settings to configure the app.  That's what is
going on as it is logging messages about starting each context up.

> Also, if I had three sevlets to auto load would I specify
> 
> <load-on-startup>
> 3
> </load-on-startup>

The number in the <load-on-startup> entry is not the number of servlets
to start -- it is supposed to define the *order* in which all
load-on-startup servlets you declare are started.  (I don't think Tomcat
3.2.1 obeys the ordering request -- Tomcat 4.0 does -- but it does start
them).

The way you declare that you want a servlet loaded at startup time is to
say so in the servlet definition for that servlet:

	<servlet>
		<servlet-name>MyServlet</servlet-name>
		<servlet-class>com.mycompany.mypackage.MyServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

You can declare as many servlets as you like in a web.xml file, and any
or all of them can be declared to load at startup time.

The details for everything that can go in a web.xml file are in the
servlet spec, which you can download at
<http://java.sun.com/products/servlet/download.html>.  There are also
starting to be articles and books about servlet 2.2 -- try doing a web
search for "servlet 2.2" and see what you get.

> 
> Peter

Craig McClanahan

Mime
View raw message