getResourceAsStream() just retrieves files from Jar?
843841Nov 28 2005 — edited Nov 29 2005Hello all,
I have a Servlet 2.4/JSP 2.0 App running on Tomcat 5.5.9 on GNU/Linux. When I want to load a file resource from within my webapp, I only manage to do so from Jar files within my app.
As soon as I want to load static files from my webapp, it fails. I tried to load file from under WEB-INF and the context root, e.g.:
/sample.txt
and
/WEB-INF/sample.txt
I tried to do so in different contexts:
SomeBean.getClass.getResourceAsStream()
SomeBean.getClass.getClassLoader().getResourceAsStream()
...getSession().getClass().getResourceAsStream()
...getSession().getClass().getClassLoader().getResourceAsStream()
...getSession().getServletContext().getClass().getResourceAsStream()
...getSession().getServletContext().getClass().getClassLoader().getResourceAsStream()
etc. but nothing works.
I cannot dig further into it. Are there any limitations not mentioned in the API docs? I googled around but did always find examples not telling where exactly the file is in the setup. Only on Oracle.com I found a sample where they load a file from below /WEB-INF...
I also tried to pass the app's context name and everything w/ and w/o leading slash. I think iit has to do with the "package" name mentioned in the docs, cos the Jar file shares the same base package like my Servlet...
Any ideas?
Thanks for any hints,
Regards,
Timo