I have Jersey rest services running on tomcat. I'm returning a Response object for a rest call, but the entity of the payload is a list of objects of a class that i defined. How can i set the content-length in the response header for this List
@Path("/somePath")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response myRestAPI(@CookieParam(value = "value") String cookieValue) {
/*..
* some business logic here
*/
List<MyObject> myObjects = getMyObjectList();
return Response.ok(myObjects).cookie(createCookie(value)).build();
}
I intend on setting the content-length header in the Response object as
return Response.ok(myObjects).header("content-length", length).cookie(createCookie(value)).build();
How can i find the length of the list? Thanks in advance