tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony GUILLOTEAU <antony.guillot...@systeme-u.fr>
Subject Rép. : Executing custom action on deploy
Date Tue, 11 Oct 2005 09:37:31 GMT
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

>>> telegraph.road@gmail.com 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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message