- contentType = contentType + ";name=\"" + name + "\"";\r
- response.setHeader("Content-Disposition",\r
- "attachment; filename=\"" + name + "\"");\r
+ contentType = FORCE_DOWNLOAD;\r
+ String ext = FilenameUtils.getExtension(name);\r
+ // cf. http://en.wikipedia.org/wiki/Internet_media_type\r
+ if ("csv".equals(ext))\r
+ contentType = "text/csv";\r
+ else if ("pdf".equals(ext))\r
+ contentType = "application/pdf";\r
+ else if ("zip".equals(ext))\r
+ contentType = "application/zip";\r
+ else if ("html".equals(ext))\r
+ contentType = "application/html";\r
+ else if ("txt".equals(ext))\r
+ contentType = "text/plain";\r
+ else if ("doc".equals(ext) || "docx".equals(ext))\r
+ contentType = "application/msword";\r
+ else if ("xls".equals(ext) || "xlsx".equals(ext))\r
+ contentType = "application/vnd.ms-excel";\r
+ else if ("xml".equals(ext))\r
+ contentType = "text/xml";\r