Reputation: 3
We have a Java web application which generates reports and serves them directly as a binary response. Until recently we were only generating PDF files (which are opened by the browser directly) this way, but recently we added the ability to generate the report as an XLS file as well. This seems to be creating issues in Internet Explorer when selecting "open" in the "what do you want to do" popup box.
The URL that serves the report is of the form "http://localhost:8080/ias/ReportsClientInterface?req=fetch&jobid=2352837_1609341332985". The MIME type we are setting is "application/vnd.ms-excel" and the Content-Disposition header is "filename=[name].xls" where [name] can vary based on the title of the report. In Internet Explorer (11 running on Windows 10) the browser shows a "what do you want to do with [filename]?" popup. The [filename] on the popup correctly shows the file name specified by the Content-Disposition header. If "save" is selected, the name chosen for the file is matching that header as well. However, when "open" is selected, Excel shows ReportsClientInterface (which is in the URL as shown above) as the name, instead of the expected report name. Worse, if we leave Excel open and generate a second report, Excel will refuse to open it because the second report also attempts to open with the name "ReportsClientInterface".
Is there a way to force IE/Excel to honor the file name specified in the headers so this issue does not occur?
Thanks in advance.
Upvotes: 0
Views: 459
Reputation: 102872
Is there a way to force IE/Excel to honor the file name specified in the headers so this issue does not occur?
Rephrasing your question: "Is there a way to remotely fix this IE11 bug"?
The answer is, obvious but disappointingly: Of course, no, there is not.
The usual fix is to mess with your server's routing system. You don't want the URL to be http://localhost:8080/ias/ReportsClientInterface?req=fetch&jobid=2352837_1609341332985
, you want it to be http://localhost:8080/ias/report/descriptiveNameOfReport/[name].xls?jobid=2352837_1609341332985
Note that as a more general note, having ReportsClientInterface
in your URL is extremely ugly and indicative that in general you've messed up on the routing part of writing web services. URLs are important. Pay more attention to them, and do not accept any routing system that results in such a mess (routing = the process that runs to tie a URL, such as /ias/ReportsClientInterface
, to some handler - the java code that you wrote that is to respond to this. That's calling 'routing').
I'm assuming that you are using an automated routing system, i.e. that you have, perhaps, a class named ReportsClientInterface
and the routing system in place uses this to automatically load classes. Or that you have some system that will produce e.g. XML that links this URL to your class.
Either way, look at the web framework you have and figure out how to take control of the routing, and then take a moment to inventory every service and page you expose, and think of a nice URL scheme for all of that. Then implement this.
Every webframework routes differently, so without knowing which one you use I can't go in further detail about how to do that job.
Upvotes: -1