title: Display pdf in browser using a rest service
body: <p>I am generating a pdf with japser reports and I would like to create a REST web service that will return this pdf and display it in the browser. I have already tried the code displayed here:</p>
  
  <p><a href="https://stackoverflow.com/questions/9295510/rest-web-services-method-to-display-pdf-file-in-browser">REST web services method to display pdf file in browser</a></p>
  
  <p>But in this way the pdf file is downloaded. I would prefer it to be displayed in the browser first and then if the user wants he could download it later.</p>
  
  <p>(sorry for the duplicate question, but as you can see the above question has not been answered... )</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Working REST Service Code:</p>
  
  <pre><code>@GET
  @Path("/pdf")
  @Produces("application/pdf")
  public javax.ws.rs.core.Response getPdf() throws Exception
  {
      File file = new File("E:\\tmp\\test.pdf");
      FileInputStream fileInputStream = new FileInputStream(file);
      javax.ws.rs.core.Response.ResponseBuilder responseBuilder = javax.ws.rs.core.Response.ok((Object) fileInputStream);
      responseBuilder.type("application/pdf");
      responseBuilder.header("Content-Disposition", "filename=test.pdf");
      return responseBuilder.build();
  }
  </code></pre>