Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Rendering ByteArrayOutputStream in IE through struts.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am facing a peculiar problem while rendering binary files in IE through servlets. Actually I read binary files stored as BLOB from the database (DB2) and render them on the internet explorer using a servlet (struts action class). This is the code i use to render the files;

byteArrayOutputStream = //get byteArrayOutputStream from the database.
ServletOutputStream sos = null;
StringBuffer sbContentDispValue = new StringBuffer();

sbContentDispValue.append("attachment");
sbContentDispValue.append("; filename=");

sbContentDispValue.append(sFileName);
response.setHeader(" Content-disposition",sbContentDispValue.toString());
response.setContentLength(byteArrayOutputStream.size());
response.setContentType("application/octet-stream");
response.setHeader("Cache-Control", "max-age=30");
sos = response.getOutputStream();
byteArrayOutputStream.writeTo(sos);
sos.flush();

When I run my application on windows (using WSAD 6.0), I get a open/save/cancel dialog box. But the moment I run the application from a unix system which has Websphere 6.0, I only get a save/cancel dialog box. Besides, the filename displayed in the dialog box is improper. I tried using the content type as "application/unknown", "application/x-download". But nothing seems to be working. Has anyone of you faced a similiar problem before? Any help would be most welcome.
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!