• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Displaying images stored in the database

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm saving image files (bmp, jpg, gif) in the database as binary data (I'm using SQL Server). Then, I have to retrieve this file and show the image in a JSP.
I'm using Struts 1.1, SQLServer and weblogic.
How can I do this?
Thanks
 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest first to get a connection to the database and in someway to get a Collection of 'binary data images'; then, applying the same pattern used to convert images from their format to binary format, but on the way back, use the <html:image> Struts tag to display it on your page.
My 2 cents.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was looking for a good solution to the same problem a couple of months back.
This solution may not be the best, but It was the only one I could find at the time - performance was ok using MySQL but awful on DB2 - you'll have to see for yourself.
Anyway, I used a helper servlet to get the binary data from the DB - here's the code...

The in my jsp I have...

Hope this helps.
Regards
Dave.
 
Mary White
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Dave, your suggestion was really good
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mary
Not used it myself but you could have a butchers at the JDBC 2.0 Blob interface
Found these links
http://java.sun.com/j2se/1.4/docs/guide/jdbc/blob.html
http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBGet/index.html
The interface seems to reduce the amount of code you need to write but it might be an alternative.
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic