Originally posted by Ben Souther:
... try:
<img src="${pageContext.request.contextPath}/images/myImage.gif" />
I agree with all of your facts. But Tomcat is not cooperating.
Here's some more detail - maybe you can help me find the problem:
1. I TRIED YOUR GOOD SUGGESTION
My href="<%=basePath%>Rules.html"
and img src="<%=basePath%>images/libback.gif"> (note that basePath has an ending slash in it)
have the identical effect as when I change to the syntax based on your suggestion:
... ="${pageContext.request.contextPath}/images/myImage.gif"
I verified that the browser's Properties on these links yields the correct absolute paths.
The resulting absolute URLs for my GIF and html become these according to the browser:
http://localhost/myapp/Rules.html and
http://localhost/myapp/images/libback.gif respectively.
These seem correct, but Tomcat does not want to serve them up.
But Tomcat does not treat these absolute URLs as expected.
The GIF displays as a broken [x] symbol on my jsp's page,
and if I click the html link, the browser just redisplays my jsp page.
It doesn't even given me a page not found or complain.
2. I TRIED ENTERING THE URLS DIRECTLY
I have even tried entering these absolute URLs in the browser address field directly.
Tomcat just does not revise the page, and doesn't complain.
As a sanity check, when I enter an absolute URL to the these same files which I copied again to webapps/ROOT, and webapps/ROOT/images,
Tomcat displays them fine. (e.g.
http://localhost/Rules.html works fine). So there isn't anything wrong with the files themselves or the ability to serve them via an absolute URL to ROOT on purpose.
3. MAYBE A CLUE: TOMCAT DISPLAYS MY jsp page WHEN IT DOESN't FIND INTENDED FILES
I am wondering why Tomcat doesn't complain when it can't find the files instead of just redisplaying my jsp page.
It's as though Tomcat thinks the URL is addressing a directory and then displaying the default welcome page for .html or .gif .
But this can't be: I've checked all of the web.xml files in my Tomcat installation, and none of them
mention my application .jsp as the default welcome page or anything.
Thanks again in advance for your kind expert help
[ January 23, 2006: Message edited by: john findler ]
[ January 23, 2006: Message edited by: john findler ]