Is there a way to initialize the ServletContext for a webapp on a Resin server using a method? I need something like that runs once, when the server starts up.
That's for `Servlet` initialization, not `ServletContext` initialization.
skaffman
2010-01-22 16:50:05
But the Servlet object has access to the ServletContext at that point, right?
Zach
2010-01-28 16:08:06
+1
A:
You need to use a ServletContextListener
.
http://www.java-tips.org/java-ee-tips/java-servlet/how-to-work-with-servletcontextlistener.html
This J2EE tip demonstrates use of ServletContextListener. This event class handles notifications about changes to the servlet context of the Web application that they are part of. This can be explained as if someone is present on the server and dynamically informing us about the events that are occuring on the server. There acquire need of Listners. Therefore, ServletContextListner is helpful in informing about context Initilazation and destruction.
skaffman
2010-01-22 16:49:35