If you have a Servlet 2.3 compatible container (e.g. Tomcat 4.x or later) you can implement a ServletContextListener which will be notified when your context is started and gives you access to the ServletContext.
... import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; public class StartUpListener implements ServletContextListener { public void contextInitialized(ServletContextEvent evt) { MyBean bean = new MyBean(); evt.getServletContext().setAttribute("MyKey", bean); } public void contextDestroyed(ServletContextEvent evt) { // Whatever shutdown processing you need goes here. } } Listeners are configured in web.xml: <listener> <listener-class>myapp.StartUpListener</listener-class> </listener> Another way that is Struts specific but also works with Servlet 2.2 containers is to implement a PlugIn. ... import org.apache.struts.action.ActionServlet; import org.apache.struts.action.PlugIn; import org.apache.struts.config.ModuleConfig; public class MyPlugIn implements PlugIn { public void init(ActionServlet servlet, ModuleConfig config) throws ServletException { MyBean bean = new MyBean(); servlet.getServletContext().setAttribute("MyKey", bean); } public void destroy() { // Whatever shutdown processing you need goes here. } } A PlugIn is configured at the end of your struts configuration file (struts-config.xml) See the Struts example webapp for a demonstration of plugins: ... <plug-in className="myapp.MyPlugIn"/> Finally, you could create a Servlet that runs automatically at start up and set-up any ServletContext attributes in it's init() method. My preference is to use a ServletContextListener if possible, or a PlugIn. Steve > -----Original Message----- > From: Kannan [mailto:[EMAIL PROTECTED] > Sent: October 7, 2003 8:35 AM > To: Struts Users Mailing List > Subject: setting application context > > > Hi all! > I have a lot of drop down menus in my web application. > I need to set them as collection objects in servlet context. > that should load up when the application ( tomcat start..) load up. > Then i can play with struts by iterating it.. > > Can any one help me , How to do this? How to write the loader class and > set it up...? > > thanks in advance. > Kannan. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]