You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@comcast.net> on 2004/02/29 21:16:47 UTC

Re: image not displayed

Peter,

> Since i am new to Tomcat i installed tomcat 5 on a Suse 8.2 linux machine and tried to install the First Webapp Servlet example.
> I have placed all files in subdirectories of myapp, thus:
> myapp/src/mypackage/Hello.java, 
> myapp/web/WEB-INF/web.xml 
> myapp/web/image/tomcat.gif
> 
> After ant install and starting a local browser, the text output is shown correctly but the image is not displayed. I cant figure out why the image isn't shown. Did i mis something in the web.xml? (see below)

web.xml is probaly not your problem. What does your 'ant install' do?

Are you using Tomcat standalone? If so, your context path (in 
server.xml) should point to the directory where your WEB-INF and 'image' 
directories are. If you are using Tomcat's auto-deploy feature and just 
shove your files into {tomcat-home}/webapps/myapp, then make sure your 
image path is {tomcat-home}/webapps/myapp/image. Also, make sure that 
your URLs for the images in your web page look like this:

<img src="http://host/myapp/image/tomcat.gif" />
or
<img src="/myapp/image/tomcat.gif" />

...or they are relative to your actual web page or JSP. I recommend 
against this, since you then get lots of <img 
src="../../image/whatever.gif" /> which gets unmanageable after a while, 
especially if you start including some JSPs in others where the paths 
aren't always the same relative to the root.

-chris