title: Client vs server image process and shown
body: <p>Client vs server imagen process.</p>
  
  <p>We got a big system which runs on JSF(primefaces) EJB3 and sometimes JavaScript logic (like for using firebase and stuff).</p>
  
  <p>So we run onto this problem, we have a servlet to serve some images. Backend take a query, then extract some blob img from DB, make that BLOB into array of bytes, send it to browser session memory and servlet take it to serve it in <strong>ulr-OurSite/image/idImage</strong>. Front end calls it by <strong><code>&lt;img&gt;(url/image/id)&lt;/img&gt;</code></strong> and works fine so far.</p>
  
  <p>Then we are using a new direct way to show img, we send <strong>BLOB/RAW</strong> data to frontend <strong>and there</strong> we just convert them into Base64.imageReturn. and pass it to html.</p>
  
  <pre><code> Base64 codec = new Base64();
                  String encoded = codec.encodeBase64String(listEvidenciaDev.get(i).getImgReturns());
  </code></pre>
  
  <p>Both work, for almost all cases.</p>
  
  <p>Note: We didn't try this before because we couldn't pass the RAW data through our layers of serialized objects and RMI. Now we can of course.</p>
  
  <p>So now there are two ways.</p>
  
  <p>Either we send data to servlet and put it on some url, which means the backend does all the job and frontend just calls url </p>
  
  <p>or we send data to frontend which is going to make some magic and transform it to img.</p>
  
  <p>This brings 2 questions.</p>
  
  <ol>
  <li><p>If we send to frontend RawObject or make them call URL to show his image content, final user download the same amount of data? This is important because we have some remote branch offices with poor internet connection </p></li>
  <li><p>Is worth pass the hard work to frontend (convert data) or backend (convert and publish)?</p></li>
  </ol>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>My questions is not about BLOB (<strong>the one i call RAW data</strong>) being bigger than base64</p>
  
  <p>It is; passing the data as object and transform it to a readable picture is more heavy to internet bandwidth than passing a url from our servlet with the actual IMG and load it on html ?</p>