title: Setting ETAG/LastModified on Representation sent by ServerResource
body: <p>I know I can set the ETAG and LastModified properties on Representation/Repre​sentationInfo.
  But I have a simple resource implemented like this :</p>
  
  <pre><code>public class AccountServerResource extends ServerResource implements AccountResource {
  
      private static Logger log = Logger.getLogger(Acc​ountServerResource.c​lass.getName());
  
      @Override
      public Account retrieve() {
          User user = getClientInfo().getUser();
          AccountDAO dao = new AccountDAO();
          Account ret = dao.getAccountByEmai​l(user.getEm​ail());
          log.info("retrieved " + ret);
          // getResponse().getEntity() == null at this point !!!
          // ---&gt; cannot do this : getResponse().getEntity().setModificationDate(ret.getLastMod​ified());
          return ret;
      }   
  }
  </code></pre>
  
  <p>The representation is not yet attached to the response at this time.
  When/how do I set the ETAG/LastModified tags ?</p>
  
  <p>What is the recommended practice here ?</p>
  
  <p><strong>---UPDATE---</strong></p>
  
  <p>I tried this approach without luck :</p>
  
  <pre><code>@Override
  public Account retrieve() {
          User user = getClientInfo().getUser();
      AccountDAO dao = new AccountDAO(user.getN​amespace());
          AccountDAO dao = new AccountDAO();
          Account ret = dao.getAccountByEmai​l(user.getEm​ail());
      log.info("retrieved " + ret);
      setOnSent(new StrongEtagCallback​&lt;Account&gt;(ret));​
      return ret;
  }
  </code></pre>
  
  <p>And implementation of the StrongEtagCallback like this :</p>
  
  <pre><code>public class StrongEtagCallback&lt;T extends DomainResource&gt; implements Uniform {
  
      private static SimpleDateFormat df = new SimpleDateFormat("dd​MMyyyyHHmmssSSS");
      private DomainResource d;
  
      public StrongEtagCallback(T domainResource) {
          d = domainResource;
      }
  
      @Override
      public void handle(Request request, Response response) {
          String eTag = d.getClass().getSimpleName() + "-" + d.getId() + "-" + df.format(d.getLastModified());
          response.getEntity().setTag(new Tag(eTag, false));
      }
  }
  </code></pre>
  
  <p>Where all my entities implement DomainResource which require them to have an ID and LastModified date.</p>
  
  <p><strong>But it does NOT work. I really expected this to work, it is very elegant !</strong></p>
  
  <p>The StrongEtagCallback is being called though, the ETAG set server-side on the entity. My Wireshark nor my GWT client sees a E-TAG header on the response of the response. Diving deeper now.</p>