Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

servlet file download works in Firefox but not IE 6

843841Jan 13 2005 — edited Oct 28 2008
We're trying to store some user-generated reports in the database and then let the user view/download them (both HTML and CSV versions). On Firefox, the CSV one brings up the browser's file download box like it's supposed to, and it even puts the filename I told it to as the default save name ("ShipmentReport" + accountnbr + ".csv"). However, for IE 6, it gets to the point where it asks you if you want to save the file, but then when you click either Open or Save, it pops up with another windows that says:
Internet Explorer cannot download ...eport?type=export&id=database from 63.999.87.432.
Right before it pops up the file download box, you can see this in the status bar:
Redirecting to site:  https://63.999.87.432/mainapp/Report?type=export&id=database
As I mentioned above, in Firefox, by the time it gets to the file download box, it doesn't ask you if you want to save "...eport?type=export&id=database" --- instead it has the latter part of "ShipmentReport2973847299.csv" or something like that (as it's supposed to).

Here's relevant the code in my servlet for both the HTML and CSV versions:
    response.setHeader("Pragma", "No-cache");
    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");

    if (type.equalsIgnoreCase("html")) {
      response.setContentType("text/html");
      response.setHeader("Content-Disposition", "inline; filename=ShipmentReport" + accountNbr + ".html");
    } else if (type.equalsIgnoreCase("export")) {
      response.setContentType("text/plain");
      response.setHeader("Content-Disposition", "attachment; filename=ShipmentReport" + accountNbr + ".csv");
    }
    String pseudoFile = new wwxchange.utility.ResourceHandler().getReport(id, type);
    PrintWriter out = response.getWriter();
    if (type.equalsIgnoreCase("html")) {
      out.println("<html>");
      out.println("<head><title>ShipmentReport" + accountNbr + "</title></head>");
      out.println("<body>");
    }
    out.println(pseudoFile);
What am I doing wrong???
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 25 2008
Added on Jan 13 2005
47 comments
4,126 views