To solve this pbm, I saved the file's name into DB as well, so in the code:
get the file name as well:
String savePath = "attachment; filename=\"" + fileName.replace('\\', '_') + "\"";
then add in this line:
response.setHeader("Content-Disposition", savePath);
following are the same as urs:
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream servletOutputStream = response
.getOutputStream();
servletOutputStream.write(bytes);
you can have a try...