title: How to detect if a PDF data object is loaded/dsiplayed/valid in html object
body: <p>My goal is either to detect the presence of PDF object (or) validate the PDF/stream if the PDF is displayed/failed to load.</p>
  
  <p>Tried different solutions available/suggested but nothing worked. Would highly appreciate for any suggestions to achieve any of these(detect the presence of PDF object (or) validate the PDF/stream if the PDF is displayed/failed to load.)</p>
  
  <p>Here is the sample code i'm using to display the PDF on my page.</p>
  
  <p>In displaying JSP:</p>
  
  <pre><code>&lt;Object id= "main_content" type="application/pdf" frameborder= "0" scrolling="auto" marginheight= "1" align="top" height = "197px" WIDTH="100%" data="sample.jsp"  standby="Loading document..."&gt;Oops, you have no pdf viewer enabled.&lt;/Object&gt;
  </code></pre>
  
  <p>In processing JSP:</p>
  
  <pre><code>String pdfData ="some data in base64 encoded stream"
  byte[] byteArr = pdfData.getBytes(); 
  byteArr = Base64.decodeBase64(byteArr);
  response.reset();
  response.setContentType("application/pdf"); 
  response.setHeader("Content-disposition", "inline; filename=\"sample.pdf\""); 
  OutputStream output = response.getOutputStream();
  output.write(byteArr);
  output.close();
  </code></pre>