• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Weblogic and the downloading of documents

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What content type are you using for MS Word and the image files?
 
Chris Mathews
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW, this type of code is better handled inside of a Servlet instead of a JSP.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic