title: GetEntity vs ReadEntity in Response (Javax.ws.rs)
body: <p>I am writing a client to consume a RestService and I have to read an entity out of the response and I am totally confused which method out of the two (<code>getEntity</code> vs <code>readEntity</code>) should be used.</p>
  
  <p>I have to retrieve the entity whenever I get a WebApplicationException.</p>
  
  <p>So, my code more or less looks like.</p>
  
  <pre><code>catch(WebApplicationException ex) {
  // Do something with ex.getResponse
  }
  </code></pre>
  
  <p>From, whatever I have tested, </p>
  
  <pre><code>ex.getResponse().hasEntity() ---&gt; true
  
  ex.getResponse().getEntity() == null ---&gt; true
  </code></pre>
  
  <p>I don't know how it is working but if the first is true then how second statement could be true.</p>
  
  <p>Surprisingly, readEntity worked fine for me and I was able to read the 
   entity out from the response.</p>
  
  <p>But, after reading the entity through readEntity, </p>
  
  <p>this call gives false. </p>
  
  <pre><code> ex.getResponse().getEntity() == null --&gt; false
  </code></pre>
  
  <p>Can someone help me understand what is really happening behind the scenes?</p>