Jump to content
  • Wrong response MIME type for XLS, XLSX and DOCX formats through report execution API

    CategoryBug report
    StatusFeedback Requested

    Respose header for content type is not properly set up when asked a report execution output.

    For example, when we ask an execution for XLS output format, we get the response:


    "status": "ready",

    "totalPages": 1,

    "currentPage": null,

    "errorDescriptor": null,

    "requestId": "1901846579_1404312812586_5",

    "reportURI": "/reports/EDB/live_assignments",

    "exports": [


    "status": "ready",

    "errorDescriptor": null,

    "outputResource": {

    "contentType": "application/xls",

    "fileName": null


    "id": "xls"





    As we can see, contentType is set up as "application/xls" and should be "application/vnd.ms-excel" for XLS output according to IANA (http://www.iana.org/assignments/media-types/media-types.xhtml) or Microsoft (http://technet.microsoft.com/en-us/library/ee309278%28office.12%29.aspx).

    The other types we found out to be wrong were XLSX ("application/xlsx" is set up when should be "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") and DOCX ("application/docx" is set up when should be "application/vnd.openxmlformats-officedocument.wordprocessingml.document").

    User Feedback

    Recommended Comments

    Changed Assigned User from - to @User_306070

    Same Problem here. Selected format Jasperserver response should bexls application/xls application/vnd.ms-excelxml text/xml application/xmlrtf unknown application/rtfIs there an option to set these types?
    Link to comment
    Share on other sites

    In our particular case, we tried the next approaches:


    - we implemented a servlet filter class that tried to detect the wrong MIME type for the response, e.g.: when the response header had the Content-Type header set to "application/xls" we tried to change it to "application/vnd.ms-excel".

    This turned out not to work given the response is flushed after being processed by the web service end point.


    - we checked the MIME types mapped on the conf/web.xml file on the embedded Tomcat and it was properly set. Apparently, setting anyone of this mappings to a dummy MIME type (e.g.: dummy-application/dummy-type) doesn't change anything, JasperReports keeps responding as before, so evidently it doesn't get the MIME types for the response from here.


    - we implemented a servlet filter class to try to set the Content-Disposition header of the response in the cases when we knew that the MIME type was wrongly set. As we knew that the response was flushed after being processed by the web service end point, we set the header BEFORE being processed as "Content-Disposition: attachment; filename='filename.extension'". This turned out to work, and we were able to download the file with an appropriate file extension.


    Given that the last solution was like "hacking" the application and not like configuring it, we decided to give a chance to the last release version of JasperReports Server at the time, v5.6.0, and apparently on this release the MIME type of the response was correctly set, so we finally get to a proper solution for our problem. But despite of this, we never could determine what was exactly the cause behind, or even find some documentation about this or how to configure these MIME types.


    We hope that our experiences on this issue serves to anyone that walks into the same "rock".

    Good luck!

    Link to comment
    Share on other sites

  • Create New...