mime-type tag in web.xml and attachment download
843838Mar 1 2007 — edited Mar 1 2007i have set a mime-type in web.xml as below:
<mime-mapping>
<extension>xls</extension>
<mime-type>application/vnd.ms-excel</mime-type>
</mime-mapping>
And i have a simple jsp that only shows a table and i am making this jsp to get downloaded as an excel attachment. To make it possible i have written the following line in the JSP:
response.setHeader( "content-disposition", "attachment; filename=myexcel.xls" );
But i am not setting the content type first by writing:
response.setContentType( "application/vnd.ms-excel" );
since i have already mentioned the appropriate mime-type for excel files in web.xml.
I am using both mozilla and IE. Both are showing file download dialog. But IE is able to correctly identify the type of the attachment and opens it up with Microsoft Excel whereas mozilla fails to identify the type, assumes it to be an HTML document and opens it up in a new window of IE.
mozilla works fine only when i set the content type in the JSP itself. But IE works in all conditions even without having the mime-type tag in web.xml.
If i have already specified the mime-type for particular type of file in web.xml, is there any requirement to set the content type again in the JSP/servlet?
Please help. I even changed the mime-type for .xls (excel) files in web.xml and made it text/plain, but still the same thing is happening. IE is always showing the correct file type where as mozilla is taking it as an HTML document.
i am using weblogic server 8.1.