Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Not able to display image from the object retrieved back from the database into the jsp page.

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have used struts 2 framework and ejb3 .
Here i am posting all my codes..

1.index.jsp
2.ImageAction.java for persisting the whole Image object into the database.
3.ShowImage.java for retrieving the desired object from the database.
4.display.jsp where image will be shown.
5.Images.java Images Entity Bean.

code.1



code 2



code 3.



code 4..



code 5.


Please help me.
I am stuck on this.

Thanks for helping me.

Regards
Shashank Pratap.


 
Greenhorn
Posts: 25
Oracle PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


In here, you are trying to output all the binary data of the image to 'src' attribute of the image html tag. See the html source of the generated code and you can verify that.

What you should have done is set the value of the 'src' attribute to a servlet which print the binary data stream of the image using a output stream and set the content type of that output response to relevant image mime type.

e.g.:

Where relevant servlet mapped to "/imgegenerateservlet.do" URL will read the image (can use a variable similar to which I have mentioned here 'imgid' to select the relevant image) from the database and set thecontent type of the response to an image related mime type such as 'image/jpeg' and then write the image data to the response using output stream.
I am not much familiar with EJB related things. So I don't know how to achieve this using EJB related stuffs.

Thanks & Regards,
Manjula
 
Ranch Hand
Posts: 109
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi shashank,

Manjula is correct you have to use servlet to find image and write that image stream into the response. This tutorial perhaps help you http://balusc.blogspot.com/2007/04/imageservlet.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic