This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes Loading a properties file from the bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Loading a properties file from the bean" Watch "Loading a properties file from the bean" New topic

Loading a properties file from the bean

Celina Joseph

Joined: Aug 23, 2001
Posts: 24
I have to load a properties file from a bean.This bean is called from the jsp page.
The properties file is in the same folder as the jsp page.But how do I get the correct path in the bean to load the property file.
If I call the System.getProperty("user.dir"), it gives me the path to the folder before the jsp page.(Not the one where the jsp and the property file is).My jsp lies in the following path -
c:\\prgram files\allaire\JRun\servers\default\time
and the path returned by System.get...
c:\\program files\JRun\servers\default
I don't want to add the folder Time to the path in the code b'coz it may change in different environments.
(This is in extension with my earlier mail.Though the complete problem is detailed out here.)
chin josei

Joined: Jun 22, 2001
Posts: 25

U can put the properties file in classpath
and read using System.getProperty("java.class.path").
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

If you put the properties file on the class apth then it's actually easier than that:
Drop it on the class path, use ClassLoader.findResource to get a handle on the file (via a URL) then open an InputStream and read it.

I agree. Here's the link:
subject: Loading a properties file from the bean
jQuery in Action, 3rd edition