You can write a ServletContextListener that calls your method from the contextInitialized() method. For example, you attach a listener to webapp in web.xml, for example.
<listener> <listener-class>my.Listener</listener-class> </listener>
and
package my; public class Listener implements javax.servlet.ServletContextListener { public void contextInitialized(ServletContext context) { MyOtherClass.callMe(); } }
Strictly speaking, this only starts once when webapp starts, and not when Tomcat starts, but it can mean the same thing.
skaffman Oct 01 '08 at 16:01 2008-10-01 16:01
source share