title: Generate a PDF document and open it in a new window with java bean
body: <p>I'm trying to generate a PDF document and open it in a new window. I create a Servlet to create the PDF and in my backing bean I have this code:</p>
  
  <pre><code>public void viewReport(){
          try {
              FacesContext.getCurrentInstance()
                 .getExternalContext().redirect("/app/report.pdf?type=sb");
              return;
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  }
  </code></pre>
  
  <p>and in my page I have this:</p>
  
  <pre><code>&lt;h:form target="_blank"&gt;
  &lt;h:commandButton action="#{clientBean.viewReport}" value="#{msgs['button.view']}"/&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>The PDF is ok but it opens in the same window. How can I open the PDF in a new window from bean?</p>