How to change the title of a browser page which a servlet streamed a PDF to?

后端 未结 5 746
情歌与酒
情歌与酒 2020-12-09 04:55

My Java based webapp has a servlet which streams PDF content back to the browser based on request parameter.

e.g. user clicks on an A tag with an href of \"myApp/Fet

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 05:42

    I have tried a solution in java and it worked. You can set given headers in other languages

    response.setHeader("Content-Disposition","inline; filename=\"MyFile.pdf\"");
    response.setContentType("application/pdf; name=\"MyFile.pdf\"");
    response.getOutputStream().write(pdfAsBytesArray);
    

提交回复
热议问题