title: opening pdf stream in new window using javascript
body: <p>I am using <code>struts2</code> framework and <code>dojo</code> for ui. I want to display a pdf in new browser window. I am getting pdf inputstream from server via normal ajax call get method(didnt use dojo ajax call. used native js ajax call ).<br>
  How to view pdf string in a new browser window?</p>
  
  <h2>js code:</h2>
  
  <p>/<em>two inputs to get pdf file</em>/</p>
  
  <pre><code> var selectedFileSlot={"END407":"report_28_03_13.pdf","END408":"[B@cef121c","END409":"*.pdf;*.doc;*.docx;*.odt;*.ods","END410":"5242880"}
          var selectedNode=   {"objectID":"22df1b2601a3552f24e5f011abc27f86","specID":"2001","entityConcreteID":"11000"}
  
  
      var xmlhttp;
      if (window.XMLHttpRequest) {
          xmlhttp=new XMLHttpRequest();
      } 
      xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)  {
            alert(xmlhttp.response);
            window.open(xmlhttp.response);//not able to open in new browser window
        }
      }
      xmlhttp.open("GET","downloadDocument.action?selectedNode=" + JSON.stringify(selectedNode) + "&amp;selectedFileSlot=" + JSON.stringify(selectedFileSlot),true);
      xmlhttp.send();
  </code></pre>
  
  <h2>struts.xml code:</h2>
  
  <pre><code>&lt;action name="downloadDocument" class="commonAction" method="downloadDocument"&gt;
      &lt;interceptor-ref name="sessionStack"&gt;&lt;/interceptor-ref&gt;
      &lt;interceptor-ref name="cachingStack"&gt;&lt;/interceptor-ref&gt;
      &lt;result name="success" type="stream"&gt;
      &lt;param name="contentType"&gt;application/octet-stream&lt;/param&gt;
      &lt;param name="inputName"&gt;inputStream&lt;/param&gt;
      &lt;param name="contentDisposition"&gt;attachment;filename="${fileFileName}"&lt;/param&gt;
      &lt;param name="bufferSize"&gt;1024&lt;/param&gt;
      &lt;/result&gt;
      &lt;/action&gt;
  </code></pre>
  
  <h2>action class code:</h2>
  
  <pre><code>commonDTO.setSelectedNode(this.selectedNode);
  commonDTO.setSelectedFileSlot(this.selectedFileSlot);
  byte[] bytes = commonDAO.getDownloadDocument(commonDTO); //getting pdf as byte array
  inputStream = new ByteArrayInputStream(bytes);
  </code></pre>