• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to retrive img from database through jsp  RSS feed

 
Pramod_Job
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,
I am making a Auction site.But problem arise is I know how to store a img file through java into database.But I don't know through JSP.
I am using back end as a Oracle.& I am used BLOB datatypes for storing a img file. I want code for storing & retrieving a img file from oracle database & this img file again view to user through html.If anyone have a idea. pls. give response as early as possible
(pramod_job@rediffmail.com)
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP are designed to receive and send character data, not binary images. You should use a servlet. This question has come up frequently on this forum so if you search I bet you will find more information.
Bill
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Pramod_Job"
Your name doesn't follow the javaranch guideliens on names. Please take a moment and change your "Publicly Displayed Name" by modifying your profile.
Thanks for your cooperation.
- madhav
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you insist on doing it with a jsp, try this:
byte[] image = // get yuor image as bytes.
response.setContentType("image/gif");
out = response.getOutputStream();
out.write(image);
etc.
watch out not to accidentally send anything else out (like whitespace) into the response or it will fail. whitespace will by default go back as text/html and you cant change the content type after the client has had stuff returned to them already - aka content has been comitted.
chanoch
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!