title: How can I disable Websphere's 8.5 default 4xx message?
body: <p>I have a Jersey REST application in Websphere 8.5. Whenever my resource responds with a 4xx response, Webpshere (or IBM Http Server) overwrites the response body with its default error message, for example: </p>
  
  <blockquote>
    <p>Error 404: Not Found</p>
  </blockquote>
  
  <p>Not only don't I want the response body to be overwritten, I want the response body as produced by my resource, but also Websphere does not update the <code>Content-Length:</code> response header, thereby creating an inconsistency between content-length and the actual response body length.</p>
  
  <p>Is there a way to force Websphere (or IBM HTTP server) to <strong>not</strong> overwrite the response body when my resource produces a 4xx response?</p>
  
  <p>For example a call to the following resource:</p>
  
  <pre><code>@Path("timeout")
  public class TimeoutService {
      @GET
      @Path("withbody")
      @Produces(MediaType.APPLICATION_JSON)
      public Response getWithBody() {
          Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
  
          builder.entity("{ \"status\" : \"notok\" }");
          return builder.build();
      }
  }
  </code></pre>
  
  <p>will result in:</p>
  
  <pre><code>Error 404: No
  
  Request Method:GET
  Status Code:404 Not Found
  Response Headers
  $WSEP:
  Connection:Keep-Alive
  Content-Language:en-US
  Content-Length:13
  Content-Type:text/html;charset=ISO-8859-1
  Date:Tue,21 Apr 2015 11:50:38 GMT&gt;
  Keep-Alive:timeout=15, max=100
  X-Powered-By:Servlet/3.0
  </code></pre>
  
  <p>Note how the default message gets truncated because of the inconsistent content length.</p>
  
  <p>But what I want is this call to respond with a <code>404</code> and <code>{ "status" : "notok" }</code> and <code>Content-Type</code> set to <code>application/json</code></p>