Or, if your init method is not in a servlet class, you may want to have
your class implement the ServletContextListener interface. Then the
method contextInitialized() is your friend, it is called by tomcat for
each implementor upon initialization of your web app context, i.e. the
"startup" event of your web application.

Robert

> -----Original Message-----
> From: Antony GUILLOTEAU [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, October 11, 2005 11:38 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Rep. : Executing custom action on deploy
>
>
> In your web.xml file, declare a servlet like this :
>
>     <servlet>
>         <servlet-name>myServlet</servlet-name>
>         <servlet-class>xx.xx.xx.myServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>
>
> And in your servlet, the init() method is called when the
> server start :
>
>
> import javax.servlet.ServletConfig;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
>
>
> public class myServletextends HttpServlet
> {
>   /** Init */
>   public void init(ServletConfig config) throws ServletException
>   {
>     super.init(config);
>     // do your action
>   }
>
>   public void doGet(HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException
>   {
>    // ...
>   }
>
> }
>
>
> Antony
>
> >>> [EMAIL PROTECTED] 07/10/2005 18:32:03 >>>
> Hi!
>
> I'm writing a web application for tomcat and I have a strange request:
> I would like to execute an initializing function in order to
> initialize correctly my applicaiton when it becomes available
> (deployed into tomcat or tomcat itself is started)
>
> I have written such behaviour in a method, so what can I do
> to execute it?
>
> Thanks for your help, Matteo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to