users@jersey.java.net

[Jersey] Problem with binary/excel files, https and IE

From: Ralph Soika <ralph.soika_at_imixs.com>
Date: Thu, 14 Apr 2011 20:32:12 +0200

Hi,

I have a strange problem concerning a Get Method dealing with an Excel
File via a HTTPS connection.
On the first look everything is fine and works as expected. My method
looks something like this:


    @GET
    @Path("/data/{id}.xls")
    @Produces("application/vnd.ms-excel")
    public Response getResultExcel(final @PathParam("id") String filename,
             final @Context UriInfo uriInfo) {
        byte[] excelWorkbook = excelGenerator.copyExcelWorkbook(filename);
        if (excelWorkbook!=null) {
            Response.ResponseBuilder builder = Response.ok(excelWorkbook);
            builder.header("Content-disposition",
                            "attachment;filename=" + filename);
             return builder.build();
         } else
           return Response.status(Response.Status.NOT_FOUND).build();
    }


I can request the file from the browser and excel opens the file.
But on IE there is a problem when using the service via HTTPS. IE seems
to open the file twice. A request like '/data/myfile.xls' results in
excel in a filename like "myfile[1].xls". Opening the file via Firefox
the filename becomes "myfile.xls". This all should not be a problem. But
some of my excel files have embedded PivotTables. And during the
download through IE via HTTPS the datasources inside the Pivotable broke
because of an internal caching from IE.

It seems that this problem - providing binary files through IE via HTTPS
connections is well known. See:
http://xmlgraphics.apache.org/fop/1.0/servlets.html#ie
http://marc.info/?l=fop-user&m=105336061115375&w=2
http://support.microsoft.com/default.aspx?scid=kb;en-us;293792


I can't figure out how to control the cache settings in a way that the
file download works on https connections. We have an older
implementation (more than 6 years old) with an simple httpServlet
without any special header params. This servlet works in our
environment. But we whant to migrate the app to JAX-RS/Jersey.

Can anybody help me with this problem?

===
ralph