wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes img tag does not display image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "img tag does not display image" Watch "img tag does not display image" New topic
Author

img tag does not display image

Varun Nayudu
Ranch Hand

Joined: Jun 26, 2006
Posts: 157
i am using trying to display an image on my starting screen but i am not able to see the image on the browser. The Jpg image file and the jsp in which i want to how the image are in the same folder (web-app/Pro)Pro is my Project name.Bur still i am unable to get the image.

<img src="Header.jsp" height="300"/>

Header.jsp is the jsp in which i want to show the image.
i am using Dreamweaver to make the jsp and it is display the image on it but when i run the tomcat and view the Webpage its giving a blank screen.
[ October 14, 2008: Message edited by: Bear Bibeault ]

SCJP 1.5, SCWCD 1.5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45
The src attribute of the img tag must point to the image itself (a JPEG, GIF or PNG), not to some other page that in turn shows the image.


Ping & DNS - my free Android networking tools app
Varun Nayudu
Ranch Hand

Joined: Jun 26, 2006
Posts: 157
i dont want to show only the image i want to show some other things which i am going to pas to that page as parameters. That is why i want to show the JSP page and not the image.
Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

A JSP page can not be considered as an image. For displaying a jsp you have to use include.

Regards
Ananth Chellathurai


Ananth Chellathurai [Walk on software]
stef li
Greenhorn

Joined: Jan 16, 2006
Posts: 27
it will doesn't work if you set the src to the jsp page if the jsp page doesn't return am image stream.

if you want to show the pic and contain some other params, i suggest you to use iframe.


This guy is so lazy!!!<br />There is nothing left!
Rachel Swailes
Ranch Hand

Joined: May 18, 2004
Posts: 434
It turns out (much to my amazement) that you can actually have the src parameter of an image tage point off to another jsp.

Have a look at using a jsp to output a binary stream and an example of why you might want to do this.
[ October 14, 2008: Message edited by: Rachel Swailes ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45
you can actually have the src parameter of an image tage point off to another jsp

That's not a good idea. It may work in certain circumstances, but there are servlet containers where it simply will not work. You just shouldn't use JSPs for binary content. It's bad design to have Java code in JSPs, anyway.
Mark Smith
Greenhorn

Joined: Jun 29, 2005
Posts: 3
What would be the correct way to display dynamically created images in a java servlet?
Rachel Swailes
Ranch Hand

Joined: May 18, 2004
Posts: 434
Ulf, I agree that this probably isn't the best way to accomplish this. I was just commenting that (while it's not a brilliant way to go about it) it is technically possible.

And I completely agree that Java code in jsp's is a very bad design!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

Originally posted by Mark Smith:
What would be the correct way to display dynamically created images in a java servlet?
The <img> tag's src should reference a servlet (not a JSP, never a JSP) that streams the image data.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nicola Seidita
Greenhorn

Joined: Nov 05, 2008
Posts: 1
Hi!
I use a servlet to get image data from db and write image on page.
on tomcat it runs very well but on OAS it doesn't works.
I think that i need to set something like url-patterns in web.xml
but I can't find out what.
Any ideas?

thanks in advance
 
 
subject: img tag does not display image
 
Similar Threads
images in HTML/JSP
Image is not displaying after Submit
How to show image in jsp from any where using browse button?
Screen resolution
Unable to get authentication and authorization working.