Thursday, December 31, 2009

“Internet Explorer Cannot Download” Error Message When You Use HTTPS URL


Internet Explorer will not display attachments when HTTPS is used. This bug has been documented in the link below.
If  the development environment is not using HTTPS this issue will be
identified only at a later stage when we move on to integration testing
environment where we normally use HTTPS.
The following are the steps to be followed for the workaround.
1. In the Servlet code please use the below snippet.
1response.reset();
2//If the report type is other than PDF handle accordingly]
3response.setContentType("application/pdf");
4response.setHeader("Content-Disposition","attachment; filename=Report.pdf");
5 
6//pragma can be set to other available options also.
7response.setHeader("Pragma""public");
8response.setHeader("Cache-control""max-age=30");
9//The logic to write into the OutputStream goes here.
Note: The reset of HttpServletResponse is very important.
Following are to be ensured on the browser (client).

1. Ensure Do not save encrypted pages to disk check box is not selected in Internet Explorer.
2.  Incase of IE 7, ensure the automatic prompting for downloads is enabled
under Tools–>Internet Options–>Custom Level –> Downloads.

No comments: