Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placement of .properties files

Status
Not open for further replies.

bvallet

Programmer
Apr 10, 2001
52
0
0
US
If I create my own *.properties file, where would I have to place it to be accessible from the individual servlets? I'm running on Websphere 4.0.

Would putting it in the root with the various html files work? What would I need to put for the path? I want to do something like this:
Code:
InputStream in = new FileInputStream(filename + ".properties");
Any help would be appreciated. Yes, I'm new to servlets.
 
This is a perfect case for using the ServletConfig and the init() method to find your file. You declare your property file path as a servlet init parameter in which ever way your app server requires and then in your init() method, you get the parameter with the servlet config:

void init(ServletConfig config)
{
String props_file = config.getInitParameter("props.file");
...
}

Be sure to give the FQ pathname as the init parameter. Alternately, you can store your props file in your servlet context and retrieve the file relative to the context in a similar fashion.

Regards,

Charles
 
Thanks, I'll try the ServletConfig option and go from there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top