File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Loading a properties file from the bean" Watch "Loading a properties file from the bean" New topic
Author

Loading a properties file from the bean

Celina Joseph
Greenhorn

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...
is
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
Greenhorn

Joined: Jun 22, 2001
Posts: 25

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

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.

Dave.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading a properties file from the bean
 
Similar Threads
What should System.getProperty("user.dir") return when called from a bean ?
how to import class into jsp file
Running JSP using JRun Server
relative path name for propertiesObject.load()
How to get the Codebase path?