File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Loading Property files using Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Loading Property files using Struts" Watch "Loading Property files using Struts" New topic

Loading Property files using Struts

Mohammed Yousuff
Ranch Hand

Joined: Apr 18, 2006
Posts: 45
How can i load the property files smartly using struts Framework.As per my project requirement, i like to load any of the 3 property files based on the environment (like development,QA and production environment).Please let me know how it can be achieved . Thanks in advance.

Regards<br /> <br />Mohammed Yousuff M N <br /> <br />Try NOT to Become a man of SUCCESS, BUT Try to Become a man of VALUE..
Santosh Ramachandrula
Ranch Hand

Joined: Apr 04, 2004
Posts: 252
I normally do it during the build process where I can specify the environment.

Other than this I am guessing that we will have to write some kind of logic with in application class loader that picks up the environment specific property file(You may have to bundle all the environment specific property files along with your jar/war/ear).

Would be interested in knowing if other alternatives can be used.

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One of my clients accomplished this using Java System properties (System.getProperty()). They set an Environment property for each of their environments (PROD, QA, Or DEV). The application logic would then look at this property and load the appropriate properties file.

Consultant, Sima Solutions
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

One of my clients accomplished this using Java System properties (System.getProperty()).

I remember seeing a similar thing, but instead of setting it as a System property, the env-entry in the web.xml was used for achieving the same.

[My Blog] [JavaRanch Journal]
I agree. Here's the link:
subject: Loading Property files using Struts
It's not a secret anymore!