This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Cannot Download PDF (streamed) in IE with HTTPS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cannot Download PDF (streamed) in IE with HTTPS" Watch "Cannot Download PDF (streamed) in IE with HTTPS" New topic

Cannot Download PDF (streamed) in IE with HTTPS

David Le Strat

Joined: Mar 27, 2003
Posts: 2
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.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 ( != -1 ) {
if (mDebug) {pRequest.logDebug("ReportRetrieval:service. Buffer length " + length);}
bufferLength = bufferLength - length;
if (bufferLength < length) {
length = bufferLength;
if (0 == length) {
buff = null;
buff = new byte[length];
if (mDebug) {pRequest.logDebug("ReportRetrieval:service. Content length: " + byteArrayOutputStream.size());}

The problems only happen with IE under HTTPS, all other browser work find.
Any suggestion would be very appreciated.
David Le Strat

Joined: Mar 27, 2003
Posts: 2
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:
To fix this, I reset my response: pResponse.reset() and set only the header fills needed for my stream.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Kept you up all night - didn't it .

"JavaRanch, where the deer and the Certified play" - David O'Meara
Dirk Holbeck

Joined: Oct 29, 2003
Posts: 2
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 !
I agree. Here's the link:
subject: Cannot Download PDF (streamed) in IE with HTTPS
Similar Threads
Response as PDF
Rendering ByteArrayOutputStream in IE through struts.
CANNOT download file from https in IE 6
Serving PDF with my servlet - performance & non-display
Problem with downloading files