• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image problem with JSP

 
Abiodun Okusolubo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out this simple jsp code,

<img src="tomcat.gif"> <br>
<img src="header.gif"> <br>
<img src="jakarta-logo.gif"> <br>

The irony is I created the header.gif using paint, the other two gifs were copied from tomcat examples. The problem here is I can't load any image I create except those copied from tomcat examples. I also created images using adobe photoshop, still no way around it.

However, when run the same code in html, exactly the same situation.

Is there anything I am doing wrongly or is there anything about how tomcat reads images that is not specify in the Headfirst servletandjsp text book I am using.
However, the servlet version I'm using is version 5.0.

Any advice will be welcome

Thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the HTML/Javascript forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Images are images; they'll either display or they won't. And whether the img tag is in a plain html page or one dynamically generated, via JSP or otherwise, is moot.

Firstly, are the URLs correct? You are using a relative URL which can be iffy.

Secondly, do the images display in the browser when open them directly (File > Open..)?
If not, something is wrong with your image files. If so, then the URLs are the most likely culprit.
 
Abiodun Okusolubo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I must thank you very much for your reply.
All the images and, html and jsp are in the same folder. Without using the Tomcat container, all the images worked as the should.
But as soon as I run tomcat and then comes the problem. I also noticed when i changed the Image type for the okay images to jpg, they also failed to show up.
This problem shows up when I am using tomcat to test the site I am building.

thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the HTML sent to the page to see if it formatted as you think it should be.

Since your problem seems to be Tomcat-specific, I'm shifting this topic to the Tomcat forum.

You didn't set any funky mime-type mappings in the Tomcat config, did you?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, MS-Paint can only create bitmaps ".bmp".
It is possible that you gave a ".gif" extension to a bitmap file?

I'm thinking that the browser is figuring out the file type when you hit it directly from the file system but getting confused when fetched via Tomcat because Tomcat is seeing the "gif" extension and sending incorrect mime-type instructions.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paint can create GIFs as well as BMPs (and JPEG, TIFF, PNG), but the default is indeed BMP. As suggested, make sure that your image is really a proper GIF, and not some other format with a ".gif" extension.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic