title: Convert base64 byte array to an image
body: <p>I have a form bean with attributes id, desc and imageByteArray. Struts action gets executed and it redirects to a JSP where i want to access these bean attributes like id, desc and convert the imageByteArray and display it as an image. I tried this <a href="https://stackoverflow.com/questions/943729/how-to-display-an-image-which-is-in-bytes-to-jsp-page-using-html-tags">post</a>, but that's not working for me.</p>
  
  <p>I encode the bytearray using Base64 - where this.bean.imageByteArray refers to the form bean</p>
  
  <pre><code>this.bean.setImageByteArray(new org.apache.commons.codec.binary.Base64().encode(imageInByteArr));
  </code></pre>
  
  <p>I tried this, but not working</p>
  
  <pre><code>&lt;img src="data:image/jpg;base64,&lt;c:out value='${bean.imageByteArray}'/&gt;" /&gt;
  </code></pre>
  
  <p>Byte array (byte[] imageByteArray) refers a base64 encoded JPG image and I'm getting the following img tag as output and obviously nothing gets displayed,</p>
  
  <pre><code>&lt;img src="data:image/jpg;base64,[B@2e200e"&gt;
  </code></pre>
  
  <p>Any idea how to convert base64 byte array and display as an image in JSP?</p>