JavaExample.net | Web application initialization at startup on tomcat or jboss AP

1) listener based:
we define a listener in the web.xml of our web application

 
	my.package.mylistener
 

we create a new java class that implements ServletContextListener and we can use following method to hook the startup

public void contextDestroyed(ServletContextEvent event)
{
    myDestroyLogic();
}

2) servlet based
we define a new servlet in web.xml like following tag

 
        myServletName
        my.package.myServlet
        1
 

well, now we can use following method to hook the startup

public void init(ServletContext context) throws ServletException
{
   myLogic();
}

Tagged with →  
Share →

Leave a Reply

Your email address will not be published. Required fields are marked *