users@glassfish.java.net

Re: Images not displaying on webpage

From: Wolfram Rittmeyer <w.rittmeyer_at_jsptutorial.org>
Date: Thu, 07 May 2009 17:37:47 +0200

coreyharden wrote:
> I've been attempting to get images to display on my webpages with no success.
> I've tried everything but nothing seems to work. I'm using the
> Netbeans/Glassfish bundle. When I'm editing the pages in Dreamweaver, the
> images will display but when I launch my app to the web from netbeans the
> images will not display. The only way I've found to get the images to show
> is by uploading them to photobucket and using their external link. I have
> stored the images under WEB-INF/jsp/images. I hope this question isn't too
> beginnerish :)


Everything under WEB-INF _must_ never be visible. This is so per spec
(Servlet spec). Even JSPs are accessible only if you forward to them
(e.g. from within a servlet). This is done deliberately to prevent
attackers (or curious people in general) to see the source of your JSPs
and gain valuable information that you do not like to share.

Also WEB-INF contains the configuration file web.xml, the libraries (in
WEB-INF/lib) and possibly other configurations which also should never
be visible from a client.

Images on the other hand of course should be accessible. So you could
move your "images"-directory into the web-root (in NetBeans the
logical "Web Pages"-folder in your project view [which is the
"web"-folder in the files-view]). Using this structure an image named
"imageOne.png" would be accessible from outside by using the url
http://someHost/images/imageOne.png".


--
Wolfram Rittmeyer