Wrting InputString to 'response' by setting setContentType
Posted on 2003-02-25
I am storing a file into database -Oracle 8i blob field. Then I retrieve them and write them to the 'response' on a JSP. The code is something like this :
String mainContent = "";
certclsAttachment objAttach = null;
LFChannel channel = (LFChannel)session.getAttribute(LFConstants.CHANNEL);
if (channel != null)
// Object which contains the File in InputStream format
objAttach = (certclsAttachment)channel.getAttribute("ATTACHMENT");
// File from the database as InputStream
InputStream is = objAttach.getFileStream();
int intBufferSize = objAttach.getBufferSize();
String strAttName = objAttach.getAttName();
OutputStream os = response.getOutputStream();
int length = 0;
byte buffer = new byte[intBufferSize];
while ((length = is.read(buffer)) != -1)
But this does not show the file in IE5 ie. doesn't show the word documents in the format, neither it shows the images stored in the database.
Rather than writing it to response object , if I write it to a FileOutputStream and store it on the user's machine, it retrives the document. This means the InputStram from the database doesn't have any problem. Writing it to response is creating all the problems. Any idea what could be the reason?
If i setContentType as "application/msword" then it opens the page in word and doesn't show the word document embedded in IE5.0. Any idea why it is so?
Pls. respond as soon as possible.
Thanks and Regards,