1

I have the jsp file below:

byte[] file=null;
    String ctype ="application/pdf";
    RispostaPdf risposta = (RispostaPdf) session.getAttribute(Costanti.ATTRIBUTE_FILE_PDF);
    String docName = risposta.nomeFile;
    response.setContentType("" + ctype + "; name=\"" + docName + "\"");
    //response.setCharacterEncoding("ISO-8859-1");
    response.addHeader("Content-disposition", "inline; filename=\"" + docName + "\"");
    file = risposta.modulo;
    try {
        OutputStream outStrm = response.getOutputStream();
        outStrm.write(file);
        outStrm.flush();
        outStrm.close();
    } catch (Exception e) {
        out.println(e);
        e.printStackTrace();
    }

    //response.flushBuffer();
    session.removeAttribute(Costanti.ATTRIBUTE_FILE_PDF);

to open a pdf doc in a new tab. When i save a pdf from chrome is saved with the correct name (docName):

filename=\"" + docName +

Chrome saved Chrome named file

In IE the last version (11/10/9) is saved as downloadServletName.pdf: IE saved IE named file

Anyone know how can i change the saved file name as "filename=\"" + docName" in IE?

Milaci
  • 515
  • 2
  • 7
  • 24
  • According to [this answer](https://stackoverflow.com/a/36314312/1427878) in the duplicate they had success by setting `Content-Type: application/pdf`. In your code, you seem to be appending `; name=...` after that, possible that this messes things up, so try and remove that. – CBroe Sep 27 '17 at 14:06
  • Is the same result removing '; name=....' ;( – Milaci Sep 27 '17 at 14:17

0 Answers0