This awfully good...
----- Original Message -----
From: "Bo Xu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 5:15 PM
Subject: Re: How can I make tomcat to instantiate a class
> > ...But actually my problem was to instantiate a class when
> > tomcat boots up...so that i can use that object across sessions.Can u
> > suggest something towarsd this.
> > [...]
>
> Hi :-) I find the following is from servlet-2_3-pfd2-spec.pdf(for
> Servlet containers which supports Servlet spec2.3):
>
> *
> ...
> SRV.10.2.2 An Example of Listener Use
> To illustrate a use of the event scheme, consider a simple web application
> containing a number of servlets that make use of a database. The developer
> has provided a serv-let context listener class for management of the
database
> connection.
> 1. When the application starts up, the listener class is notified. The
> application logs on to the database, and stores the connection in the
> servlet context.
>
> 2. Servlets in the application access the connection as needed during
> activity in the web application.
>
> 3. When the web server is shut down, or the application is removed from
> the web server, the listener class is notified and the database connection
is
> closed.
> ...
>
>
> * and I think perhaps there is another way:
> - make a "startupServlet", and in its "servlet-declaration" in
> WEB-INF/web.xml, set the following:
> <load-on-startup>1</load-on-startup>
> now/so when TC is started, the "init" method of this
"startupServlet"
> will be invoked by container
> - in the "init" method in this "startupServlet", a SingleTon pattern
> "startupUtility" is instantiated: for example, by invoking a public
static
> "Factory method":
> public void init(ServletConfig config) throws ServletException{
> super.init(config);
> ...
> startupUtility.makeInstance();
> ...
> }
>
> - now after a while(instantiating time), a instance of startupUtility
is
> available
> (for example, a DBConnectionpool)
>
>
> Bo
> June 14, 2001
>
>
>