wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Problem showing .gif file in .html file from Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Problem showing .gif file in .html file from Tomcat" Watch "Problem showing .gif file in .html file from Tomcat" New topic
Author

Problem showing .gif file in .html file from Tomcat

Nancy Lee
Greenhorn

Joined: Mar 23, 2002
Posts: 15
Hi:
My system is Tomcat4.0 and Window 98.
I put a.gif and a.html files in the same directory under Tomcat4.0 but that a.gif picture simply does not show up in a.html page.
Where is the right place to put that a.gif file? Thanks in advance.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
Often people put all their images together in one directory, but it's just a practice, not a necessity.
What are you using? An img tag or a button or an input or something? Show us an example of your HTML.
Or are you using Tomcat linked to Apache?
Regards
Adam
[ May 22, 2002: Message edited by: Adam Hardy ]

I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Nancy Lee
Greenhorn

Joined: Mar 23, 2002
Posts: 15
Thanks Adam.
I put the statement <img src="a.gif" alt="a.gif">
inside <body> section. My purpose is to know the right place to put a.gif file, so I did not do any other thing in a.html file.
When I shot down the Tomcat and open a.html file directly, the a.gif picture just looks fine.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
Hi Nancy,
I'm using taglibs to display my images (in struts) which takes care of stuff like this so I'm not sure how to do it without taglibs.
However, are both the html file and the gif in the website's root directory?
If so, try <img src="/a.gif">
You could also use the <base> tag in the html header. Check out
http://www.w3.org/TR/REC-html40/struct/links.html#idx-base_URI
That would be something like
<HEAD>
<TITLE>Our Products</TITLE>
<BASE href="http://www.aviary.com/products/intro.html">
</HEAD>
But that's a bit of PITA since you would have to change the tag every time you moved the file. In struts there is a <base> taglib that just works out what the URI is, so all you need is <html:base> and it does the rest itself and so moving it isn't a problem.
Perhaps someone else knows a simpler solution!
Adam
Nancy Lee
Greenhorn

Joined: Mar 23, 2002
Posts: 15
Both the html file and gif file are in website's root directory.
I tried <img src="/a.gif"> and it did not work.
One thing I do not understand : I tried the statement <img src="tomcat.gif> and it works.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
which directory is tomcat.gif in? Not the same one surely?
Nancy Lee
Greenhorn

Joined: Mar 23, 2002
Posts: 15
The tomcat.gif is in its original Root directory. It is there all the time. I just tried it.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
I can't get a handle on what your problem might be. In my tomcat 4.0.1 the examples app works fine, I just checked it out. You don't have to do anything special. Should be just like Apache.
Have you still got the problem? Maybe it's the gif - empty or something?
Nancy Lee
Greenhorn

Joined: Mar 23, 2002
Posts: 15
Yes, I still have that problem. If I use Internet Explorer ,click the open file, go to that directory(tomcat 4.0.4 base directory/webapps/Root) and open a.html then both tomcat.gif and a.gif display on the screen. I simply could not see a.gif through http://localhost/a.gif
I am not very familiar with Tomcat system. Maybe I will figure the problem out some other time. Thanks a lot for your help, Adam.
Regards
Nancy
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
Must be a simple error - if img src=tomcat.gif works but img src=a.gif doesn't work, and both tomcat.gif and a.gif are in the same place, then it's got to be something wrong with a.gif
Try renaming it or something. When you get round to it. Good luck.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem showing .gif file in .html file from Tomcat
 
Similar Threads
Need Help starting Tomcat
Help! Where to put a bean class
PUT method of HTTP
HTML link
servlets