• Post Reply Bookmark Topic Watch Topic
  • New Topic

image display in servlet in browser  RSS feed

 
raghu.rao rao
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to display blob in browser taken from mysql in servlet can any one give code for this
advance thanks
[ January 23, 2006: Message edited by: Ernest Friedman-Hill ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

What part are you having trouble with: the database part, or the displaying part?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When talking about image display in a browser, remember that it takes two things:
1. an IMG tag in an HTML page (or direct URL link) to make a request
2. A servlet to interpret the URL and format the response
Bill
(yes, I know this is obvious but sometimes people try to cram the two together)
 
Rashid Mayes
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your JSP of HTML file you should set the SRC attribute of your image to a servlet. The servlet will read the image data from the database, set the correct content type, and stream the bytes to the browser.

For Example

HTML code:

<img src=getimage?imageId=someId>

Servlet code:




Take a look at http://fotomica.astrientlabs.com/galleries.jsp. Click around. All the images are handled by a servlet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!