title: JAX/Jersey Custom error code in Response
body: <p>In Jersey, how can we 'replace' the status string associated with a known status code?</p>
  
  <p>e.g.</p>
  
  <pre><code>return Response.status(401).build();
  </code></pre>
  
  <p>generates a HTTP response that contains:</p>
  
  <pre><code>HTTP/1.1 401 Unauthorized
  </code></pre>
  
  <p>I (not me, but the client application) would like to see the response as:</p>
  
  <pre><code>HTTP/1.1 401 Authorization Required
  </code></pre>
  
  <p>I tried the following approaches but in vain:</p>
  
  <p>1) This just adds the String in the body of the HTTP response</p>
  
  <pre><code>return Response.status(401).entity("Authorization Required").build();
  </code></pre>
  
  <p>2) Same result with this too:</p>
  
  <pre><code>ResponseBuilder rb = Response.status(401);
  rb = rb.tag("Authorization Required");
  return rb.build();
  </code></pre>
  
  <p>Appreciate your help!</p>
  
  <p>-spd</p>