title: How to get PDF content (served from a Spring MVC controller method) to appear in a new window
body: <p>I am a newbie with Spring MVC but I'm quite impressed with its capabilities.</p>
  
  <p>I am using 3.1.0-RELEASE and I have to show a PDF in response to form:form submission.</p>
  
  <p>Here is the (small) code I wrote in the controller:</p>
  
  <pre><code>@RequestMapping(value = "new_product", method = RequestMethod.POST, params = "print")
  @ResponseBody
  public void saveAndShowPDF(ModelMap map, ShippingRequestInfo requestInfo, HttpServletRequest request, HttpServletResponse httpServletResponse) throws IOException {
      saveProductChanges(map, requestInfo, request, httpServletResponse);
      httpServletResponse.setContentType("application/pdf");
      byte[] pdfImage = productService.getPDFImage(requestInfo.getRequestId());
      httpServletResponse.getOutputStream().write(pdfImage);
  }
  </code></pre>
  
  <p>This code sends the PDF byte[] back to the original window.  </p>
  
  <p>How do I get the PDF to be shown in a separate window so that I can still have the original browser window to show some other content? The best way would be to have the PDF shown using the client PDF view program (Adobe Reader, FoxIt etc.) but I would be fine with the PDF showing up in a separate browser window.</p>
  
  <p><strong>EDIT:</strong>
  I decided to set the Content-Disposition so that the browser brings up a save/open box where the user can open Adobe (with losing the main browser page).</p>
  
  <pre><code>httpServletResponse.setHeader("Content-Disposition","attachment;filename=cool.pdf");
  </code></pre>
  
  <p>Thanks everyone!</p>