TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > Java

Reading properties file from WEB-INF/classes

Java

 
 
 
Thread Tools Display Modes
Old 07-10-2007, 09:10 AM   #1
Dundonald
Guest
 
Posts: n/a
Reading properties file from WEB-INF/classes

Properties file stored in WEB-INF/classes.

There are numerous ways to read properties files, but I'd like to know
what your opinions are on the best way to read from the WEB-INF/
classes directory given that I could deploy my war file to any server
on any platform not knowing how a server is configured, i.e. with its
real paths etc.

 
Old 07-10-2007, 10:05 AM   #2
Manish Pandit
Guest
 
Posts: n/a
Re: Reading properties file from WEB-INF/classes

On Oct 7, 1:23 am, Dundonald <mark.dun...***********> wrote:
> Properties file stored in WEB-INF/classes.
>
> There are numerous ways to read properties files, but I'd like to know
> what your opinions are on the best way to read from the WEB-INF/
> classes directory given that I could deploy my war file to any server
> on any platform not knowing how a server is configured, i.e. with its
> real paths etc.


getResourceAsStream() should give you the resouece that is in WEB-INF/
classes.

http://java.sun.com/j2se/1.4.2/docs/...va.lang.String)

-cheers,
Manish

 
Old 07-10-2007, 04:11 PM   #3
Lew
Guest
 
Posts: n/a
Re: Reading properties file from WEB-INF/classes

Dundonald wrote:
>> Properties file stored in WEB-INF/classes.
>>
>> There are numerous ways to read properties files, but I'd like to know
>> what your opinions are on the best way to read from the WEB-INF/
>> classes directory given that I could deploy my war [sic] file to any server
>> on any platform not knowing how a server is configured, i.e. with its
>> real paths etc.


Manish Pandit wrote:
> getResourceAsStream() should give you the resouece that is in WEB-INF/
> classes.
>
> http://java.sun.com/j2se/1.4.2/docs/...va.lang.String)

(Also available from java.lang.Class.)

<http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getResourceAsStream(java.lang. String)>
will do the same thing rooted at the application context.
> Returns the resource located at the named path as an InputStream object.

....
> The path must begin with a "/" and is interpreted as relative to the current context root.

....
> This method is different from java.lang.Class.getResourceAsStream,
> which uses a class loader.
> This method allows servlet containers to make a resource available to a servlet from
> any location, without using a class loader.


--
Lew
 
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating classes|properties|methods programatically Andrzej Lipski VB.NET 8 02-10-2007 09:08 PM
static properties in classes question Yankee Imperialist Dog C#(C Sharp) 5 15-09-2007 04:59 AM
Accessing classes within a JAR file? utsavprabhu@gmail.com Java 4 14-09-2007 10:54 PM
Accessing classes within a JAR file? utsavprabhu@gmail.com Java 5 14-09-2007 10:49 PM
Accessing classes within a JAR file? utsavprabhu@gmail.com Java 1 14-09-2007 10:11 PM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 08:44 PM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional