You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Agarwal, Naresh" <na...@informatica.com> on 2003/09/16 11:27:38 UTC

performing init operations in webapp

Hi
 
I am developing an web application (essentially axis, the web service toolkit), which will be deployed in Tomcat.
 
Now before any client make a request to this web application, I want to  perform some *init* operations.
 
How can I do this?
 
thanks,
Naresh

Re: performing init operations in webapp

Posted by Christopher Williams <cc...@ntlworld.com>.
The easiest way is as follows:

Say your web service is called MyWebService.  Implement the class that does
the real work as a singleton class (i.e. private constructor, public
getInstance() method which returns the only instance of the singleton class,
creating it if it doesn't exist).  This class will be called something like
MyWebServiceImpl.  Your servant class will be a wrapper around the methods
in MyWebServiceImpl.  For example, say you expose a method called x, the
code in the servant class will call MyWebServiceImpl().getInstance().x().

Create a servlet for lifecycle management.  In your web.xml set the
"loadOnStartup" value to 1.  In your servlet's init() method call
MyWebServiceImpl.getInstance() and do your necessary initializing in the
getInstance() method.  In your servlet's destroy() method, call something
like MyWebServiceImpl.getInstance().shutdown() to clean up (assuming that
you've defined a shutdown() method).

Your lifecycle management servlet can do other stuff - for example acting as
the destination for post operations from any admin pages that you might
write.



Re: performing init operations in webapp

Posted by Tim Funk <fu...@joedog.org>.
2 ways:
1) init() of the Servlet
2) See ServletContextListener

-Tim

Agarwal, Naresh wrote:

> Hi
>  
> I am developing an web application (essentially axis, the web service toolkit), which will be deployed in Tomcat.
>  
> Now before any client make a request to this web application, I want to  perform some *init* operations.
>  
> How can I do this?
>  
> thanks,
> Naresh
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: performing init operations in webapp

Posted by Christopher Williams <cc...@ntlworld.com>.
The easiest way is as follows:

Say your web service is called MyWebService.  Implement the class that does
the real work as a singleton class (i.e. private constructor, public
getInstance() method which returns the only instance of the singleton class,
creating it if it doesn't exist).  This class will be called something like
MyWebServiceImpl.  Your servant class will be a wrapper around the methods
in MyWebServiceImpl.  For example, say you expose a method called x, the
code in the servant class will call MyWebServiceImpl().getInstance().x().

Create a servlet for lifecycle management.  In your web.xml set the
"loadOnStartup" value to 1.  In your servlet's init() method call
MyWebServiceImpl.getInstance() and do your necessary initializing in the
getInstance() method.  In your servlet's destroy() method, call something
like MyWebServiceImpl.getInstance().shutdown() to clean up (assuming that
you've defined a shutdown() method).

Your lifecycle management servlet can do other stuff - for example acting as
the destination for post operations from any admin pages that you might
write.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: performing init operations in webapp

Posted by Tim Funk <fu...@joedog.org>.
2 ways:
1) init() of the Servlet
2) See ServletContextListener

-Tim

Agarwal, Naresh wrote:

> Hi
>  
> I am developing an web application (essentially axis, the web service toolkit), which will be deployed in Tomcat.
>  
> Now before any client make a request to this web application, I want to  perform some *init* operations.
>  
> How can I do this?
>  
> thanks,
> Naresh
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: performing init operations in webapp

Posted by Hans Liebenberg <ha...@cambrient.com>.
Create a servlet that gets initialised on the context start up (you set that
up in web.xml),
Stick your code in the servlet's init() method
  -----Original Message-----
  From: Agarwal, Naresh [mailto:nagarwal@informatica.com]
  Sent: Tuesday, September 16, 2003 2:28 AM
  To: tomcat-user@jakarta.apache.org
  Subject: performing init operations in webapp


  Hi

  I am developing an web application (essentially axis, the web service
toolkit), which will be deployed in Tomcat.

  Now before any client make a request to this web application, I want to
perform some *init* operations.

  How can I do this?

  thanks,
  Naresh