True for the Action and Action Form, but the original code snippet is a ServletContextListener.... and that the methods get called once when the application is deployed and undeployed. At this point (since I'm no expert in the specification) I believe that the Request object is not yet available.
public class ApplicationContextListener implements ServletContextListener { private ServletContext servletContext = null; public void contextInitialized(ServletContextEvent arg0) { servletContext = arg0.getServletContext(); ApplicationBean applicationBean = new ApplicationBean(); servletContext.setAttribute("applicationBean", applicationBean); } public void contextDestroyed(ServletContextEvent arg0) { servletContext = arg0.getServletContext(); servletContext.removeAttribute("applicationBean"); } } Yeah, I think that it can be static. Does it make a significant difference if it is or is not static ? - Glenn "Niall Pemberton" <[EMAIL PROTECTED]> 10/05/2005 12:56 PM Please respond to "Struts Users Mailing List" <user@struts.apache.org> To "Struts Users Mailing List" <user@struts.apache.org> cc Subject Re: Global scope Classification The Action and ActionForm both should have the servlet variable initialized. Thats a better way of getting the ServletContext: servlet.getServletContext(); Niall ----- Original Message ----- From: "Michael Jouravlev" <[EMAIL PROTECTED]> Sent: Tuesday, May 10, 2005 5:09 PM request.getSession().getServletContext(); I guess, servlet context makes sense even without session, but this seems to be the easiest way to obtain it through the request, which is passed to your reset(), validate() and execute() methods. On 5/10/05, Nils Liebelt <[EMAIL PROTECTED]> wrote: > Can the servletcontext declared as static: > > private static ServletContext servletContext; > > Not sure about it? Makes sense to me. > > GreetZ > > Nils --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]