Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

displaying images from database  RSS feed

 
N Naveen
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
pankaj patil
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!