Downloading generated RTF/XLS file in IE6/7
Today we had to do some changes in the way the reports are generated.
Previously a new page has been opened and the content was sent to the browser. We used the following headers:
1. Content-Type – mime type of the content
2. Content-Length – length of the contents data
3. Content-Disposition – this helped us to control the name of the file which browser uses during saving.
This approach worked fine for IE and Firefox.
Now we decided to store the generated reports on the hard drive, so we generate the contents and make HttpServletResponse#sendRedirect to this file. It works fine in Firefox but stopped working in Internet Explorer. A new window is opened but then it’s closed immediately. It’s weird.
The problem here is in one of the IE security settings:
For the sites which are in the Internet zone, the setting “Automatic Prompting for File Downloads” setting is disabled. Enabling it or moving web site to the trusted sites makes the browser function properly, but it’s not convenient. Searching for a flexible way to resolve this problem now…