This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes getResourceAsStream returning null Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "getResourceAsStream returning null" Watch "getResourceAsStream returning null" New topic
Author

getResourceAsStream returning null

Sat Nar
Ranch Hand

Joined: Oct 22, 2004
Posts: 83
Hi,
I am reading a config file from a java program. Below is the code.

str = loader.getResourceAsStream(filename);

It is returning a null. I have placed the file under WEB-INF and also tried placing it under WEB-INF classes. But still its returning a null. Kindly help me out.

Thanks
Santosh Raveendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 83
can you make your requirement clear,why You need to read it as byte stream?
do You need to send this file to some location or response or You need to read the data from the file

-------------
Santhosh


SCJP 1.4,SCWCD5, SCBCD5
Thanks, Santhosh
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56202
    
  13

Perhaps it might be useful for you to let us know what filename is set to?

And if you are placing the file under WEB-INF rather than in the classpath, you should be using the ServletContext rather than the class loader.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: getResourceAsStream returning null
 
Similar Threads
using a static function in XSL
Logging question : Where should I put the log4j jar file?
Reading an XML file in a war file
question about tld
Accessing files under WEB-INF