| Author |
Image Read from Blob
|
Karthik Kris
Greenhorn
Joined: Mar 16, 2006
Posts: 7
|
|
Hi We have images stored in a Blob in Oracle Database. I was able to retrieve the bytes of the images from the blob. However in the response output I get a screen of binary characters. I tried r response.setContentType("image/gif"); as well. In this scenario it shows me a image place holder on the screen. No image is displayed here as well. Bytes are read fine from the database. I am using Oracle application server 10 g env. Thanks Karthik
|
 |
Sharath Punreddy
Greenhorn
Joined: Mar 16, 2006
Posts: 1
|
|
Try using IMG tag on the jsp with SRC as a servlet. The servlet should have the following code for reading the image: res.setHeader("Cache-Control","no-cache"); //HTTP 1.1 res.setHeader("Pragma","no-cache"); //HTTP 1.0 res.setDateHeader ("Expires", 0); //prevents caching at the proxy server res.setContentType("application/octet-stream"); java.io.OutputStream outs = res.getOutputStream(); java.io.ByteArrayInputStream in = new java.io.ByteArrayInputStream(photo); int b; while((b=in.read())!=-1){ outs.write(b); } outs.flush(); outs.close(); in.close();
|
 |
Karthik Kris
Greenhorn
Joined: Mar 16, 2006
Posts: 7
|
|
Hi I tried the above and still things are not working. I also noticed a strange and interesting behavior while testing this. The bytes I read from the blob I re directed to File Output Stream and wrote a Image File . Image file was created in the directory I specified. Image file was read perfectly by MS PAINT . However the IE shows just a image place holders. Please help me regarding this Is there any metadata I need to write image header or just having response content type image/jpeg along would suffice. Karthik
|
 |
 |
|
|
subject: Image Read from Blob
|
|
|