Do you notice some website download the PDF file from the browser and some show the on the browser?
You can set it in your Java Servlet. Checkout the following.
This will open the PDF file on the browser.
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline; filename=abc.pdf);
This will download the PDF file from the browser.
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename=abc.pdf);