File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Display BLOB contents to the client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Display BLOB contents to the client" Watch "Display BLOB contents to the client" New topic

Display BLOB contents to the client

Ramesh Bhagasra

Joined: Nov 21, 2003
Posts: 8
I want to display the blob contents in the clients window and give him the option either to open or save the contents. I am able to read the contents from Oracle Blob Field and stored the contents in the ByteArrayOutputStream object but I am not able to open the contents for the client. I am using the following code
Blob blob = resultSet.getBlob(1);
int length = (int)blob.length();
byte [] b = blob.getBytes(1, length );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.setHeader("Content-Disposition","attachment; filename="+baos );
Please help me
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12868
This sort of thing comes up all the time - browse the last few weeks of post or do a search for BLOB.
I agree. Here's the link:
subject: Display BLOB contents to the client