title: Convert byte[] to Base64 string for data URI
body: <p>I know this has probably been asked 10000 times, however, I can't seem to find a straight answer to the question. </p>
  
  <p>I have a LOB stored in my db that represents an image; I am getting that image from the DB and I would like to show it on a web page via the HTML IMG tag. This isn't my preferred solution, but it's a stop-gap implementation until I can find a better solution.</p>
  
  <p>I'm trying to convert the byte[] to Base64 using the Apache Commons Codec in the following way:</p>
  
  <pre><code>String base64String = Base64.encodeBase64String({my byte[]});
  </code></pre>
  
  <p>Then, I am trying to show my image on my page like this:</p>
  
  <pre><code>&lt;img src="data:image/jpg;base64,{base64String from above}"/&gt;
  </code></pre>
  
  <p>It's displaying the browser's default "I cannot find this image", image. </p>
  
  <p>Does anyone have any ideas?</p>
  
  <p>Thanks.</p>