This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JSP and the fly likes Properties file location. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Properties file location." Watch "Properties file location." New topic

Properties file location.

Rajul King
Ranch Hand

Joined: Apr 12, 2001
Posts: 47
I have created a simple java class that uses a properties file to read certain parameters. I then put this java class in the /WEB-INF/classes and the properties file in the /WEB-INF folder. It works fine when I run it on command line but when I try to access its results in a JSP, it throws an exception "Properties file not found".
Did any one come across this kind of problem before.
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
I think .properties files probably go in the root. But I bet you can set the location by configuring your servlet container (you didn't say which servlet container you were using).
Try something like the following:
File myFile = new File( "");
System.out.println( myFile.getAbsolutePath());
That will tell you where to put the file.

Joined: Aug 05, 2002
Posts: 15
If the property file u r using is name value pair , then u can use resource bundle to read ur property file.U can place ur property file anywhere within ur project package hierachy and read it.
e.g ur property file name is
and it is in package :
Code :
// Code to load property file
java.util.ResourceBundle rboResourceBundle = java.util.ResourceBundle.getBundle("");
// code returns the value read from a property file of a given key.
public String getPropertyValue(String keyName) {
return rboResourceBundle.getString(keyName);
I hope this will help u.
Bill Pearce
Ranch Hand

Joined: Sep 19, 2000
Posts: 53
The Properties class makes this quite easy. Use this snipit when you want to place the properties file in the classpath. This can be a folder in your /WEB-INF/classes folder, or the common/classes folder off Tomcat root (assuming you are using Tomcat).

For the above, you would place the file in the
hanumanth reddy
Ranch Hand

Joined: Jun 12, 2000
Posts: 118
put your *.properties file in the WEB-INF/classes directory
Hanumanth Reddy

<a href="" target="_blank" rel="nofollow"></a><br /> 'Add Job To Life'
I agree. Here's the link:
subject: Properties file location.
It's not a secret anymore!