users@glassfish.java.net

[gf-users] Re: how to access images in WEB-INF?

From: David Salter <davidmsalter_at_me.com>
Date: Sun, 15 Feb 2015 12:28:55 +0000

If you're using jsp's you can't serve images from the WEB-INF folder as that is disallowed by the spec. The browser asks for images from your web application and cannot ask for files inside the WEB-INF folder.

You could write a servlet that can serve images from within this folder or you could implement security and put the images in a secured folder accessible only to logged on users.

Dave.

Sent from my iPhone

> On 15 Feb 2015, at 02:53, thufir <hawat.thufir_at_gmail.com> wrote:
>
> How do I load an image from WEB-INF with JSP's? I'm using Glassfish and
> NB.
>
> Filter code:
>
> String path = filterConfig.getServletContext().getContextPath();
> contextPath = "http://localhost:8080" + context + path;
> String duke = contextPath + "/duke.gif";
>
> which results in the following html:
>
> <img src="http://localhost:8080/WebApplication/duke.gif">
>
>
> Which is fine, but any user gets to access that image. I want to move
> the image to WEB-INF so that it's not accessible for users.
>
>
> see also:
>
> http://forums.netbeans.org/viewtopic.php?t=62749