Hi Tom,
In your example, you are directing your web browser to request an image file from within the "WEB-INF" directory. Per the servlet specification your servlet engine treats the "WEB-INF" directory as a private resource. This means none of the files it contains may be served directly to a client.
Try moving your /images directory out to your applications document root and you should have more luck.
For more info. on this, check section 9.4, "Directory Structure", of the servlet spec at http://java.sun.com.
Hope that helps,
Levi Cook
Greenbrier & Russel
Madison, Wisconsin
www.gr.com
[EMAIL PROTECTED]
-----Original Message-----
From: Tom Miller [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 2:53 PM
To: struts-user
Subject: html:img tag cannot find image
Hello all,
It seems that the html:img tag is able to find images in the context
root, but not in subdirectories.
When I specify an image with the html:img tag like this:
<html:img src="green-ball.gif"/>
the images appear.
But when I specify a subdirectory like this:
<html:img src="WEB-INF/images/orange-ball.gif"/>
the images are missing when the page renders, i.e. little red X symbol
in the browser.
Here is a pared down JSP that illustrates the problem. It gives the same
results whether I include the <html:base/> tag or not.
I'm using Struts 1.0b1 and Tomcat 3.2.1.
TIA for any help.
Tom
--------------------------------------------------------------------------
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html>
<html:base/>
<head>
</head>
<body>
Dot One<html:img src="green-ball.gif"/> <% /* image shows in
browser */ %>
<p>
Dot Two<html:img src="WEB-INF/images/orange-ball.gif"/> <% /* image
missing in browser */ %>
</body>
</html:html>
--------------------------------------------------------------------------
Tom Miller
Miller Associates, Inc.
[EMAIL PROTECTED]
641.469.3535 Phone
413.581.6326 FAX