You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Aline <al...@webcaster.fr> on 2002/06/06 11:53:47 UTC

Init object in contextServlet

Hi,

Can anyone tell me how to create an object instance and put it in the
servlet context at the beginning of a web application.

Is it in the web.xml that I must declare it?

thanks.
Aline
Webcaster
T +33 (0)3 28 36 25 23
F +33 (0)3 20 13 06 04
http://www.oeilpouroeil.fr
http://www.visiodrome.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Init object in contextServlet

Posted by Phillip Morelock <su...@phillipmorelock.com>.
Hey,

Write a servlet that does this.

Extend
javax.servlet.http.HttpServlet

override the "init" method.

in this init method, do whatever it is you're doing.

In web.xml, declare this servlet like usual and put in a load-on-startup
tag.  

<servlet>
    <servlet-name>DataInitServlet</servlet-name>
 <servlet-class>com.xxx.memphis.util.DataInitServlet</servlet-class>
    <load-on-startup>5</load-on-startup>
   </servlet>

The number in load on startup indicates in what order to load them -- if I
recall correctly, lower numbers go first.

cheers
fillup


On 6/6/02 2:53 AM, "Aline" <al...@webcaster.fr> wrote:

> Hi,
> 
> Can anyone tell me how to create an object instance and put it in the
> servlet context at the beginning of a web application.
> 
> Is it in the web.xml that I must declare it?
> 
> thanks.
> Aline
> Webcaster
> T +33 (0)3 28 36 25 23
> F +33 (0)3 20 13 06 04
> http://www.oeilpouroeil.fr
> http://www.visiodrome.com
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>