Stack Exchange
How to display PDF in Web browser using ServletOutputStream
I have been trying to display a pdf report in a web browser using ServletOutputStream. So far, I am able to download the file but I cannot get it to display in the browser. Here is my code
private void initReport()
{
    DBConnection connection = new DBConnection();

     try {
         jasperPrint = JasperFillManager.fillReport(getContext().getExternalContext().getRealPath("/WEB-INF/reports/testReport.jasper"), new HashMap(),connection.getConnection());

     } catch (JRException ex) {
         Logger.getLogger(ReportBacking.class.getName()).log(Level.SEVERE, null, ex);
     }

}

public void showPDF()
{
    initReport();
     try {
         HttpServletResponse httpServletResponse;httpServletResponse = (HttpServletResponse)  getContext().getExternalContext().getResponse();

         httpServletResponse.setContentType("application/pdf");
         httpServletResponse.addHeader("Content-disposition", "inline;filename=testReport.pdf");
         ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();

         JasperExportManager.exportReportToPdfStream(jasperPrint,servletOutputStream);

         getContext().responseComplete();
         getContext().renderResponse();

     } catch (JRException | IOException ex) {
         Logger.getLogger(CertificateApplicationAddBacking.class.getName()).log(Level.SEVERE, null, ex);
       getContext().addMessage(null, new FacesMessage("Could not generate report")); 
     }

If I change the content-diposition to attachment. I am able to download the file.

Whether it downloads or displays in the browser is out of your control.  Its a setting in the browser or in Acrobat, or a combination, which only the user can change (if they know how). 
However, you could use a Flash/Silverlight app that let's you load a PDF into it, or find a way to use PDF.js by passing your PDF bytes from the server to PDF.js and having it render the PDF in the browser. Look at the examples page. Where they do:
PDFJS.getDocument('helloworld.pdf').then(function(pdf) {
  // you can now use *pdf* here
});

You can change 'helloworld.pdf' to the URL of your servlet.

I have tried your suggestion and it works perfectly in firefox but in chrome I am getting this error:                                             Resource interpreted as Document but transferred with MIME type application/pdf
