• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

img tag does not display image

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Varun Nayudu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 349
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A JSP page can not be considered as an image. For displaying a jsp you have to use include.

Regards
Ananth Chellathurai
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What would be the correct way to display dynamically created images in a java servlet?
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic