You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by SA...@bouyguestelecom.fr on 2001/05/09 17:14:56 UTC
instanciate a servlet when tomcat starts
Hi,
I've a servlet that loads properties from a file to load them in the System
properties.
I'd like this servlet to be instanciated when Tomcat starts.
With Jserv, i used the zone.properties file.
I think it must be simple, but i really don't now tomcat and all the
configuration file!
Thanks
Sandrine
Re: instanciate a servlet when tomcat starts
Posted by Andrea Mari <ma...@tin.it>.
You can use the web.xml file under conf directory. This file is very simple.
Try it!
By
Andrea
Re: instanciate a servlet when tomcat starts
Posted by Benoit Jacquemont <be...@smile.fr>.
Hi Sandrine,
You have to change (or create if doesn't exist) the web.xml file that comes
in the WEB-INF directory.
The example below is the entire content of a web.xml file that loads the
ServletInit servlet and instantiate it (to the name defined by servlet-name)
on startup. The load-on-startup property must be different than 0 to have the
servlet loaded and instantiate at the startup of the app (when tomcat starts).
Benoit
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>ServletInit</servlet-name>
<servlet-class>ServletInit</servlet-class>
<load-on-startup>-1</load-on-startup>
</servlet>
</web-app>
> Hi,
>
> I've a servlet that loads properties from a file to load them in the System
> properties.
> I'd like this servlet to be instanciated when Tomcat starts.
> With Jserv, i used the zone.properties file.
> I think it must be simple, but i really don't now tomcat and all the
> configuration file!
>
> Thanks
>
> Sandrine