Forums Register Login

using getResourceAsStream() in Servlet

+Pie Number of slices to send: Send
hi......

I want to read xml files stored in resources folder of my web application,
so I am using servlet's getResourcesAsStream() which return InputStream,
but I am not getting the Stream of the xml file and getting a NullPointerException.

please help to solve this.....!

Thank you..
+Pie Number of slices to send: Send
Welcome to JavaRanch.

What are you passing in as the parameter? Where is the file located?
[ October 06, 2008: Message edited by: Ulf Dittmer ]
+Pie Number of slices to send: Send
Based on the javadoc of ServletContext, the only way it will return null is if the resource does not exist in the path you supplied.

Please verify the the resource your are trying to load exists. If it does, then verify if you are passing the correct parameters.

The rules governing the path of the parameter in this function is referred to in the getResource function of the ServletContext. Please refer to the javadoc.

javax.servlet.ServletContext

Usually, it should start with "/" and should be relative to the current context root where the ServletContext object is created by the container.

Regards.
Whatever you say buddy! And I believe this tiny ad too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 4571 times.
Similar Threads
hi friends i am getting exception when i am using jasper reports
Escape Encoding for XML attribute
response xml
each time encryption gives different result......??
MQ Exception --- 2033 error
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:38:05.