For setting HTTP status code other than 200, we have to use javax.ws.rs.core.Response class for response. Below are some of the sample return statements showing it’s usage.
return Response.status(422).entity(exception).build();
return Response.ok(response).build(); //200