0

Where "is" WEB-INF/duke.gif? What's the path(?) to this image?

thufir@doge:~$ 
thufir@doge:~$ jar -tf NetBeansProjects/WebApplication/dist/WebApplication.war 
META-INF/
META-INF/MANIFEST.MF
WEB-INF/
WEB-INF/classes/
WEB-INF/classes/beginnersbook/
WEB-INF/classes/beginnersbook/com/
WEB-INF/classes/net/
WEB-INF/classes/net/bounceme/
WEB-INF/classes/net/bounceme/dur/
WEB-INF/classes/net/bounceme/dur/filter/
WEB-INF/classes/net/bounceme/dur/servlets/
WEB-INF/images/
WEB-INF/classes/beginnersbook/com/Details.class
WEB-INF/classes/net/bounceme/dur/filter/Auth.class
WEB-INF/classes/net/bounceme/dur/filter/AuthenticateFilter.class
WEB-INF/classes/net/bounceme/dur/filter/SessionCheckFilter.class
WEB-INF/classes/net/bounceme/dur/servlets/Controller.class
WEB-INF/classes/net/bounceme/dur/servlets/MyToken.class
WEB-INF/classes/properties.properties
WEB-INF/duke.gif
WEB-INF/fail.jsp
WEB-INF/images/duke.gif
WEB-INF/login.jsp
WEB-INF/success.jsp
WEB-INF/web.xml
duke.gif
index.html
thufir@doge:~$ 
thufir@doge:~$ glassfish-4.1/glassfish/bin/asadmin deploy NetBeansProjects/WebApplication/dist/WebApplication.war 
Application deployed with name WebApplication.
Command deploy executed successfully.
thufir@doge:~$ 
thufir@doge:~$ glassfish-4.1/glassfish/bin/asadmin list-applications
WebApplication  <web>  
Command list-applications executed successfully.
thufir@doge:~$ 
thufir@doge:~$ 

I want to reference this file, and load it in a JSP.

see also:

https://stackoverflow.com/questions/28402583/load-image-in-filter-with-getservletcontext-getrealpath

1 Answer 1

1

Use /WEB-INF/duke.gif

However, you need to access it as a resource from the servlet context.

In your JSP:

<%
   ServletContext ctx = request.getServletContext();
   InputStream stream = ctx.getResourceAsStream("/WEB-INF/duke.gif");
%>

I hope this helps...

1
  • absolutely, thanks. I didn't see any other way of getting the file, when it's in WEB-INF, except as a stream. Leaving it open for a bit just to see if anyone comes along with a way to do so.
    – Thufir
    Feb 25, 2015 at 8:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .