Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning 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
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

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.
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic