aspose file tools*
The moose likes Servlets and the fly likes Servlets, HTML and GIFs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets, HTML and GIFs" Watch "Servlets, HTML and GIFs" New topic
Author

Servlets, HTML and GIFs

Randall Stevens
Ranch Hand

Joined: Jul 01, 2003
Posts: 65
I have a servlet that gets an HTML file that has some GIFs in it. The problem I am encountering is the page is retrieved, but the GIFs are not displaying.
The html page is in jakarta-tomcat-4.0.4/webapps/ROOT
The GIFs are currently in jakarta-tomcat-4.0.4/webapps/ROOT
The html references the GIFs similiar to <img src="myLogo.gif">
On my desktop the images show, however when deployed on the server the images do not show. How can this be corrected?
Randall
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

Since you are specifying a relative reference to the images, the browser is trying to find them in the same folder as the page. However, since your page is emitted by a servlet, there really is no "page".
What the broser is doing is to use the URL of the servlet (probably a servlet mapping, no?) as the base for your relative references.
You will need to either use server-relative href's for your images, or use the <base> tag to provide a relative base for the images.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

This discussion in Apache/Tomcat talks about the same thing (after post #3) , with regard to JSPs. But the general idea is the same as this discussion.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets, HTML and GIFs
 
Similar Threads
Need help Configuring Tomcat 4.0.4 on Linux
How do you deploy a WAR file on Tomcat?
Need help with Tomcat 4.0.4 on RedHat Linux
tomcat ZipException when starting up
a simple question