• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Cannot Download PDF (streamed) in IE with HTTPS

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there,
I having fighting with a bizarre problem that pretty much consistent in all versions of IE.
I am streaming out a PDF document from an application server. Everything works fine in HTTP. However with HTTPS, I am getting the following error:
Internet Explorer cannot download ... + file name from host.
Internet Explorer was not able tto open this Internet site. The requested site is either unavailable or cannot be found.
Here is the code, I wrote to stream out the pdf:
pResponse.setContentType("application/pdf");
pResponse.setHeader("Content-Disposition", "attachment; filename=commission_" + period + "_" + rptype + ".pdf");

ByteArrayOutputStream byteArrayOutputStream = null;
byteArrayOutputStream = new ByteArrayOutputStream();
int length = BUFFERSIZE;
if (bufferLength < length) {
length = bufferLength;
}
byte[] buff = new byte[length];
while ( bufferedInputStream.read(buff) != -1 ) {
if (mDebug) {pRequest.logDebug("ReportRetrieval:service. Buffer length " + length);}
byteArrayOutputStream.write(buff);
bufferLength = bufferLength - length;
if (bufferLength < length) {
length = bufferLength;
}
if (0 == length) {
break;
}
buff = null;
buff = new byte[length];
}
bufferedInputStream.close();
pResponse.setContentLength(byteArrayOutputStream.size());
if (mDebug) {pRequest.logDebug("ReportRetrieval:service. Content length: " + byteArrayOutputStream.size());}
pResponse.getOutputStream().write(byteArrayOutputStream.toByteArray());
pResponse.getOutputStream().flush();
pResponse.getOutputStream().close();
return;

The problems only happen with IE under HTTPS, all other browser work find.
Any suggestion would be very appreciated.
Regards,
David.
 
David Le Strat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,
I found the fix to my problem:
There is a bug with IE. And as far as I tested it is still there in IE6 that results in IE not being able to open a streamed PDF under HTTPS.
Basically, this behavior will occur if the HTTP header specify any of the cache control headers:
Pragma
Cache-control
Expires
To fix this, I reset my response: pResponse.reset() and set only the header fills needed for my stream.
Regards,
David.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kept you up all night - didn't it .
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
i had the same problem with streaming excel data with https. And your hint helped there as well. One only has to be careful with userdata transported via the HttpSession Object, this will be killed as well.
Many thanks for answering your own question, so other (like me) are able to learn from your experiences !
Regards,
Dirk
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic