struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Taylor, Jason" <>
Subject RE: How to manage application properties?
Date Sun, 22 Sep 2002 18:16:42 GMT
If you want to manage properties using Struts mechanisms, you can set up a
message-resources reference to your property file (say,
"") in the struts-config.xml file right after
the action-mappings block:

parameter="com.yourdomain.application.ApplicationResources" /> 

then call the protected getResources method within any class extending

	MessageResources resources = getResources(request);

or outside an Action class (such as in the inherited ActionForm methods) do:

	MessageResources resources = (MessageResources)

The benefit here is simplicity and forward-compatibility you get from using
the built-in property mechanisms Struts gives you for free.  The downside is
the (current) awkwardness of maintaining duplicate properties if you are
using the sub-application feature, which a lot of people don't.


-----Original Message-----
From: micael []
Sent: Sunday, September 22, 2002 10:59 AM
To: Struts Users Mailing List
Subject: Re: How to manage application properties?

You can create classes and objects in struts just like you can with any 
other application.  Attached is a file with a few classes I use to teach 
students about the Properties class in java.util.  Change the value in 
Folder (line 138, if you are not using Windows).  PropertiesManager creates 
properties files from which the locations of other properties files is 
managed.  It also uses default properties, etc.


At 12:07 AM 9/22/2002 -0700, you wrote:

>This is a very "newbie" question I'm sure, so this might not be the 
>appropriate forum.  Maybe it belongs in the Tomcat forum?  Not sure.
>Pretty basic objective.... I just want to be able to put application 
>settings (things like path names, integer values, etc) in a *.properties 
>file and access those properties from within my tomcat/struts(1.1) 
>application.  I see quite a bit of talk about 
>, but it seems like people are only using 
>that to store and retrieve messages.  I'd rather not mix my messages with 
>my settings.  How do you do it?  I'm aware of the 
>class.... but I don't really know how to efficiently use it within the 
>application servlet context (I don't want to reload it with every 
>request)..... and I wouldn't know when to load it into application 
>scope.....   anyway, you see that I don't have a clue.  I can think of 
>plenty of ways to do it, but I would like know the most common/accepted 
>method(s).  So any tips would be much appreciated :)
>Do you Yahoo!?
>New DSL Internet Access from SBC & Yahoo!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message