Define a servlet say "com.guru.servlet.StartUpServlet"
And in the StartupServlet
Overide the init() Method
... init() {
super.init()
getServletContext().setAttribute("MyBean", MyBean);
}
And in WEB.XML
StartUpServlet
com.guru.servlet
You need to do something like this:
ApplicationStartup
StartUp Servlet
a.startup.ApplicationStartup
1
ApplicationStartup
/startup
This tells tomcat to run that servlet when Tomcat first intialises the
context. You can put all your initialisatio
One possible solution would be :
U create a servlet which loads on startup.
While defining servlets in web.xml set the load on startup attribute
for some servlet and that servlet will be loaded/executed
automatically by container at startup
U can write ur code for loading and populating the bean
Please don't use servlets and the load-on-startup to do this. It is a kludge.
Use a ServletContextListener(). They were intended for just this type of need.
-Tim
Raghupathy,Gurumoorthy wrote:
Define a servlet say "com.guru.servlet.StartUpServlet"
And in the StartupServlet
Overide the