Issue
Actually I am trying to preview a pdf in chrome and download it. I am writing the byte array in the servlet response object and setting the following headers.
response.setContentType("application/pdf; charset=utf-8");
response.setHeader("Content-Disposition", "inline; filename="+fileName+".PDF");
and in jsp action target="_blank".
when I click download button. PDF file is open in new tab. But when I tries to download then it is showing "network error" in chrome and other browsers except firefox.
The actual file format is like 12345.PDF Is there any contentType issue occurs bw .PDF and .pdf
Solution
Normally I use Content-Disposition: attachment; filename="foo.bar"; Try adding "attachment; filename="+fileName+".pdf"
attachment indicates resource is downloadable
Also there is a file extensions registry of known types: more info here mozilla doc [How to determine the correct MIME type for your content section] so pdf is registered while PDF isn't.
As a general fallback you could also try "application/octet-stream" writing the file as a binary stream.
Answered By - Andrew
Answer Checked By - Willingham (JavaFixing Volunteer)