I have a Spring Web Application where a user can download PDF and Excel Files. I set the HTTP header for both of them:
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.parseMediaType("application/vnd.ms-excel"));
responseHeaders.setContentLength(fileSize);
responseHeaders.set("Content-Disposition", "attachment");
responseHeaders.add("Content-Disposition", "filename=\"" + encodedFileName + '\"');
This works fine on Tomcat (the HTTP response is of mime type application/vnd.ms-excel). But on Websphere 7, the server always return content type: text/html for this request.
I have already registered the excel content type in the web sphere virtual host, but this does not change anything.
What did I missed?
Your syntax is incorrect, you can't have multiple C-D headers. Like this:
Also, the code will not work correctly when encodedFilenName contains characters outside the ISO-8859-1 character set.
(dunno whether that's related to your problem, though)