I am using HttpServletResponse
wrapped with JSF 2.1 in order to make a download button. Following the instructions of this answer: https://stackoverflow.com/a/9394237/870122
Since I want to download a csv
file, I use the following headers:
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
ec.responseReset();
String fileName = "MyFile.csv";
ec.setResponseContentType("text/plain");
ec.setResponseHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
The download completes successfully with both IE9 and FF, but with the second I see that the browser adds a ".txt" extension that I would like to avoid.