title: Download and open PDF file using Ajax
body: <p>I have an action class that generates a PDF. The <code>contentType</code> is set appropriately.</p>
  
  <pre><code>public class MyAction extends ActionSupport 
  {
     public String execute() {
      ...
      ...
      File report = signedPdfExporter.generateReport(xyzData, props);
  
      inputStream = new FileInputStream(report);
      contentDisposition = "attachment=\"" + report.getName() + "\"";
      contentType = "application/pdf";
      return SUCCESS;
     }
  }
  </code></pre>
  
  <p>I call this <code>action</code>  through an Ajax call. I don't know the way to deliver this stream to browser. I tried a few things but nothing worked.</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: url,
      data: wireIdList,
      cache: false,
      success: function(response)
      {
          alert('got response');
          window.open(response);
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) 
      {
          alert('Error occurred while opening fax template' 
                + getAjaxErrorString(textStatus, errorThrown));
      }
  });
  </code></pre>
  
  <p>The above gives the error:</p>
  
  <blockquote>
    <p>Your browser sent a request that this server could not understand.</p>
  </blockquote>