title: How to play a Audio file sent in form of byte array in HTML5
body: <p>I have a servlet which creates a byte array and sends it as response.</p>
  
  <pre><code>byte[] to_send = func(text); // function that returns a byte array.
  ServletOutputStream stream = response.getOutputStream();
  stream.write(to_send);
  stream.flush(); 
  </code></pre>
  
  <p>I am receiving the same using ajax.</p>
  
  <pre><code>var xmlhttp;
  xmlhttp=new XMLHttpRequest();
  xmlhttp.onreadystatechange=function()
  {
      if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
           {
              var a = xmlhttp.responseText;
              console.log(a);
              var audio = document.getElementById("myAudio");
              audio.src = a;
              audio.type = "type/ogg";
              }
            }
      xmlhttp.open("GET","myservlet?page=input&amp;text="+a,true);
      xmlhttp.send();
  }
  </code></pre>
  
  <p>I am receiving the giberish response text. Which I want to play using HTML5 audio control.</p>
  
  <p><code>&lt;audio id="myAudio" controls /&gt;</code></p>
  
  <p>How can I achieve that?</p>
  
  <p>Edit: I did it using data URI. I converted the Byte Array to data URI and sent it back and assigned it to SRC. Wish to know How I can do it using byte array.</p>