struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eddie Bush <>
Subject Re: How to manage application properties?
Date Sun, 22 Sep 2002 16:25:28 GMT
How many "settings" do you have?  Are they volatile?

You could:
    - specify settings as an init-param to the controller servlet.
    - specify settings as context params
    - use a properties file (as you mentioned) and look it up out of the 

To get your properties read-in, you could:
    - write an initialization servlet
    - write a context listener
    - write a struts plugin

All that your initializer (any of them) would have to do is something like: is = 

The "someObject" would vary depending on which approach you took.  There 
are methods on the Properties class to read from an InputStream.  See 
javadoc ;-)

In order to store your newly loaded properties into application scope 
(if they're not particular to a certain user, this is where you should 
put them), you'd simply do something like:


    - someObject varies by your implementation again
    - "mySpecialProps" is the key you wish to use for looking up the 
    - mySpecialProps is an instance of Properties (the one you just loaded)

C F 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 :)  

Eddie Bush

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message