Hi,
Actually, I use Weblogic 8.1 and I want a
jsp to send a stream file to the browser. This works with pdf files, but not with msword files nor with images (gif, jpg).
Here is the code I use to retrieve the InputStream and send it as OutputStream.
<%
InputStream input=(InputStream) request.getAttribute("doc");
String doc_type=(String) request.getAttribute("type");
String doc_name=(String) request.getAttribute("doc_name");
response.setContentType(doc_type);
response.addHeader("Content-Disposition", "inline;filename="+doc_name);
output=response.getOutputStream();
BufferedInputStream inr=new BufferedInputStream(input);
//Read the input stream and write the output stream by chunks.
byte[] chunk = new byte[4096];
int i=-1;
while((i = inr.read(chunk))!=-1)
{ output.write(chunk,0,i);
}
out.flush();
out.close();
%>
Any idea?