permaculture playing cards*
The moose likes Struts and the fly likes Better idea to put custom properties in struts 1.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Better idea to put custom properties in struts 1.2" Watch "Better idea to put custom properties in struts 1.2" New topic
Author

Better idea to put custom properties in struts 1.2

Muthukrishnan Manoharan
Ranch Hand

Joined: Aug 27, 2008
Posts: 91

Can anyone please suggest me a best practice for custom properties in struts 1.2, I mean where to place the properties file (under WEB-INF or somewhere else) and how to access or address them relatively from struts Action class.

Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
I put the property file in a particular place where i used to put all the property file for different appliation.

lets say
C:
|---- PropertyFiles
|----App1
|--app1.properties
|-----App2
|--app2.properties

Note : the above paths are not intended appropriately
Then in the server(Application or webserver) configuration ,i pass the path to the property file as system property via JVM argument.
like -DAPP2Prop=path to app2.properties -DApp1Property=path to app1.properties.

Then whn you run the application you can read it as System.getProperty(App2Prop) and pass it to the argument as Property constructor.

Well i am not sure this is a good idea or not? But this works atlease for me so far.

SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
Muthukrishnan Manoharan
Ranch Hand

Joined: Aug 27, 2008
Posts: 91

Thanks Siva Masilamani

But I need to package the properties file along with the war.. So I would like to know where should I drop the file in WEB-INF or somewhere else and how can I access it relatively in Action class...
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Check out here

webpage
Aditya Keyal
Ranch Hand

Joined: Dec 01, 2008
Posts: 71
The best place to put a property file in a WebApp (WAR/EAR file) would be in the src folder.

The ideal demarcation would be like this:

src
- java
- config
- resources

Now place all the property files under the resources section. The config is mainly for xml files.

You can now pick up the property using a classpath resource loader or even using struts property loader.

- Aditya Webservices Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Better idea to put custom properties in struts 1.2
 
Similar Threads
Changes in properties file should get reflected with out restarting server
Action class in Struts
Basic jars and Plugins to run struts application
NullPointerException
Customizing FormPropertyConfig