• 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

displaying images from database

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need to read a image from the database and display it as part of the jsp.The jsp has other parts - text,etc.
The architecture of my application uses struts,delegate pattern,servie pattern and then dao pattern.
i am reading the image using CachedRowSet and having it as a BufferedImage object.
But I wish to know how i can display the image onto the jsp page.
Now,the problem is that it is not the only content.
Need to display a logo.

Regards,
Naveen Nagarajan
 
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
Answer: How would you display any other image on a JSP page?
[ July 11, 2005: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a sample app with a servlet that reads images from a file and streams them to the browser. In that app there is also an HTML page that uses img tags to call the servlet with various image requests.

Once you've got the inputStream (whether from a file or a db read) the code for streaming it to the browser is the same.

http://simple.souther.us Look for SimpleStream.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when u upload an image file, u have to store the image in the database datatype(image). then while displaying the u hve to take the data from the database in the bytearray. Create a new file and write bytearray into the new file save the file as rowno or any thing else . and then make use of the <img src=" path where the file is stored " > tag .
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pankaj patil:
when u upload an image file, u have to store the image in the database datatype(image). then while displaying the u hve to take the data from the database in the bytearray. Create a new file and write bytearray into the new file save the file as rowno or any thing else . and then make use of the <img src=" path where the file is stored " > tag .




So, you're writing the image to disk every time someone wants to view it?
Why not just stream it right from the database to the browser?
 
Bear Bibeault
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
pankaj, JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

Please read this for more information.

thanks,
bear
Forum Bartender
reply
    Bookmark Topic Watch Topic
  • New Topic