Custom response header Jersey/Java

I think using javax.ws.rs.core.Response is more elegant and it is a part of Jersey. Just to extend previous answer, here is a simple example:

    @GET
    @Produces({ MediaType.APPLICATION_JSON })
    @Path("/values")
    public Response getValues(String body) {

        //Prepare your entity

        Response response = Response.status(200).
                entity(yourEntity).
                header("yourHeaderName", "yourHeaderValue").build();

        return response;
    }

Leave a Comment

tech