On Thu, 9 Jan 2003, Suresh Addagalla wrote:
> Date: Thu, 9 Jan 2003 12:18:10 +0530 > From: Suresh Addagalla <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: Application scope variables > > Hi, > > I have a few options for storing application level data, and need your > opinions on deciding on a strategy. > > My requirement is to load a couple of properties files in the > application startup and to be able to access them across all classes and > JSPs in the web application. > > 1. Using the ServletContext of ActionServlet > 2. Using the pageContext of JSP (PageContext.APPLICATION_SCOPE) These two are identical. Anything you set through one is visible through the other. > 3. Using JSTL <c:set> tag (Does Struts provide a similar tag?) The closest analog is <bean:define>. But this is not really an appropriate use of JSP pages in an MVC architecture. > 4. Any other.. > > If I use 2 or 3, will I able able to access a property in, say, the > execute method of an Action class? What's the best way to do this? > My recommendation is to set up shared stuff like this as servlet context attributes, either in a PlugIn (Struts 1.1) or a ServletContextListener (Servlet 2.3). Anything stored as servlet context attributes is instantly available as application scope beans in a JSP page, through standard JSP tags, through PageContext.APPLICATION_SCOPE, or any other way you want to do it. > Thanks, > Suresh > Craig -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

