Παρασκευή 27 Φεβρουαρίου 2009

JSPs and mime types

I have a simple request. I have an .xml file stored somewhere in my server. The file is an Excel sheet saved in .xml format. I simply point to it from an anchor in my jsp page. I want, when the user, left-clicks to it, MS-Excel (or OO Calc) to open to display the file instead of its contents being displayed inside the browser. So, I set the mime type in the anchor tag like so:

<a type="application/vnd.ms-excel; charset=UTF-8" href="<c:url value='/templates/template.xml'/>"><img src="<c:url value='/images/excel.gif'/>"></a>

The trick seems to work fine for Firefox, but alas, not for Internet Explorer. If someone knows a solution, please let me know. :-)

2 σχόλια:

cherouvim είπε...

You have to make sure the server serves it with the Content-Type: application/vnd.ms-excel.

You can do this by serving the file yourself via Java, or simply set it to your apache configuration, probably for files which match the filenames in this webapp.

JNK είπε...

Well, since it works with Firefox, the file is being served correctly from the server. :)