Following snippet show how to return the custom Response code as http response code while returning the response: import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; @Path("/") @Consumes("application/xml") @Produces("application/xml") public class Test { public Test () { } @POST public Response test() { Response response = Response.status( 4xx ).entity("Testing").build(); return response; } }
My Opinion.