• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

display image on sturts from data base

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i have a problem reated to image retrieval what i did till now i have a column in data base with blob data type
I can easily upload the image with the help of FormFile and BinaryStream but when i try to retrieve that image i face some sort of problem My problem is:--

I got the image in the resultset with the help of connection but its return type is InputStream which doesnt have the write method so that i can not write that image in the jsp page

if i didnt use InputStream and i use byte array and then try to print it again it will not print with no error so i cant not understand why this problem occurs
thanks alot
 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're going to have to "write" the image to a file, and include the path to that file from your page. Try writing to a file first, once you get that you'll see that all you need to do then is include the path to this within an image tag.

Additionally, you might want to check this forum form more on I/O issues.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another way of approaching this would be to write a servlet or struts action class that does the following:
  • get the OutputStream from the HttpServletResponse object using the getOutputStream() method
  • read the input stream and write it to the OutputStream
  • close the OutputStream and if this is a Struts Action, return a null forward
  • in your jsp, use src="myAction.do" in your <img> tag


  • In the Struts 1.2.x download, the struts-examples.war file that comes with the download contains an example of how to do this. Look for org.apache.struts.webapp.exercise.ImageAction
    [ October 19, 2005: Message edited by: Merrill Higginson ]
     
    keep an eye out for scorpions and black widows. But the tiny ads are safe.
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic