title: Can't display StreamedContent in Primefaces media in JSF
body: <p>I have a dynamically generated PDF using iText in JAVA. 
  Bean Property: </p>
  
  <pre><code>ByteArrayOutputStream baos = new ByteArrayOutputStream();
  Document document = new Document(PageSize.LETTER);
  pdfWriter = PdfWriter.getInstance(document, baos);
  //iText code here
  ByteArrayInputStream stream = new ByteArrayInputStream(baos.toByteArray());
  StreamedContent file = new DefaultStreamedContent(stream,"application/pdf","Sds.pdf");
  </code></pre>
  
  <p>So, the bean property returns this file variable of StreamedContent type. When I use  tag, it works like a charm. But, when I use media object as follows: </p>
  
  <pre><code>    &lt;p:media player="pdf" height="500" width="400" value="#{beanName.beanProperty}"&gt;&lt;/p:media&gt;
  </code></pre>
  
  <p>I get an alert "File does not begin with %pdf-" and in the console, it says </p>
  
  <pre><code>"org.primefaces.application.PrimeResourceHandler handleResourceRequest
   SEVERE: Error in streaming dynamic resource. Expression cannot be null"
  </code></pre>
  
  <p>I have tried using iframes too but no luck. Basically, I am trying to embed a frame on a webpage in which the dynamic PDF I generate can be loaded automatically as soon as the page loads. Static URLs work but dynamic content doesn't! I have tried various solutions.
  Primefaces downloadLink works but primefaces media doesn't. BTW, I am trying to do achieve this in IE9. (It doesn't work on Chrome either). 
  I'd really appreciate any help. Thank you!</p>