tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jillian.Rei...@WellsFargo.COM
Subject RE: Setting Path for properties file
Date Thu, 22 Aug 2002 15:16:39 GMT
Justin, 

Thank you for the solution. It is working great. 
FYI... The syntax was slightly different for implementation. 

Properties prop = new Properties(); 
prop.load(this.getClass().getResourceAsStream("/MyProperties.properties"));

With this syntax I just put the file in the WEB_INF/classes directory and
the ClassLoader found it there. 

-----Original Message-----
From: Justin Ruthenbeck [mailto:justinr@nextengine.com]
Sent: Wednesday, August 21, 2002 4:47 PM
To: Tomcat Users List
Subject: Re: Setting Path for properties file



Jillian --

Instead of loading the properties from the file, you can load it 
dynamically as a system resource, then pass the InputStream into a new 
Properties object.  This way, you'll be able to load the properties file 
from anywhere in the classpath instead of just a hardcoded logical path in 
the filesystem.  For example:

this.getClass().loadResourceAsStream("/my.props");
Properties props = new Properties(inStream);

The properties file will be loaded by the ClassLoader associated with your 
webapp, so you'll have to put the props file in a directory that that 
ClassLoader can access.  I've never tried it, but I would think you could 
just place it in the WEB-INF/lib directory (can anyone confirm/refute?) 
directly.  If not, you could always jar it up and place it there.

justin


At 02:19 PM 8/21/2002, you wrote:
>I am using a properties file for my Java Beans/classes to reference
>directly.  I am having problems determining where I specify the path so
that
>my classes can find the file in my application's directory. Right now the
>only way I can read the file is if I put it in my Tomcat\bin directory.  I
>would like to be able to put the file in my application's directory
>structure instead of into Tomcat's.  Is there a way to specify this?
>
>Jillian Reiman
>Phone:  612-667-8741
>jillian.reiman@wellsfargo.com
>
>--
>To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail:
<mailto:tomcat-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message