On Dec 11, 2007 9:31 PM, sarat.pediredla <[EMAIL PROTECTED]> wrote: > > Is there anyway to specify some code to run only when the web application > context starts up? I am using Appfuse 2 with Struts 2. > > Basically, I want my basic lucene index to be created the first time I > start > my application. I did think of putting this in an custom Struts 2 > Interceptor but I dont really want it to run on every page load. Same goes > for a filter inside web.xml. > > Is there anything inside struts 2 or the standard servlet spec which > allows > me to run startup code? > > Hi Sarat,
You can implement ServletContextListener, specifically it's contextInitialized method. http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletContextListener.html AppFuse2 should have a StartupListener class that implements ServletContextListener. -- Ealden Esto E. Escañan http://ealden.net
