This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes display a picture stored in a DB with HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "display a picture stored in a DB with HTML " Watch "display a picture stored in a DB with HTML " New topic
Author

display a picture stored in a DB with HTML

bequibeck
Greenhorn

Joined: Feb 07, 2002
Posts: 1
I have to store picture in a DB and then I must display them in a web page with HTML,but to display a picture in HTML we have to give the path of the picture and not directely the picture.Is there an other solution?Help me please...
And Can I use ImageIcon in a JSP page?
[ February 07, 2002: Message edited by: bequibeck ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
For pictures from a database your link should go to a servlet which uses the request information to get the image as a byte array and serve it. You must set the content type and it works best if you set the content length.
Bill
Laurent Sate
Greenhorn

Joined: Dec 18, 2001
Posts: 10

You must set the content type and it works best if you set the content length.

Could you explain me more in detail your solution? Maybe a little example?
Thanks
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
"bequibeck"
Your name doesn't agree with the javaranch guidelines. Please take a moment and edit your profile after reviewing the guidelines at http://www.javaranch.com/name.jsp
Please change your Publicly Displayed name to follow the guidelines.
thanks for your cooperation.
- satya


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
Wow, Bill, that is an absolutely excellent solution. I never would have thought of just serving a gif as a byte array.
Is it a major performance issue though? I mean, how much slower would it be than just having images in a directory? Would the app server cache the response?
Thanks
Adam


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: display a picture stored in a DB with HTML
 
Similar Threads
window object
wml?
Forward servlets
how to display html email? thanks!
How to display database picture in thumbnail view ?