How do I load a file from inside a WAR file?

Bozidar Dangubic

[getClass().getResource() is the wrong approach, since the WAR file is not in the current classloader's path. getServletContext().getResource() should work, but apparently fails under WebLogic. Fortunately... -A]

I have done the same thing many times using ctx.getResourceAsStream("/rel-path/filename") and it always works fine. I am not sure what is the problem in your case. try to access the file using getResourceAsStream() and see if that works.

Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact