users@jersey.java.net

Re: [Jersey] ResponseBuilder and Response questions

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Fri, 27 Jun 2008 09:51:45 -0700 (PDT)

Hey Paul,

Sorry, would have helped if I listed what I was doing.

So correct me if I am wrong, but I thought in a response their was a header called body that contains the response body to send back.. json, xml, whatever it may be. So when you set the Content-Type to say json, the body header would be set to the json text string going back to the callee. Honestly I don't know where I got this from, it's probably wrong. Looking at what you wrote it seems the .entity() might be where I stick the contents xml or json in.

I have a method signature like so:
@GET
@ProduceMime("application/xml")
public Response getXml() {

At the end I use this to return:

ResponseBuilder r = Response.status(Response.Status.OK);
r.header("body", sb.toString());
return r.build();

So I am guessing this is wrong? It sounds like from what you wrote I should do:

return r.status(200).entity(sb.toString()).build();

?



It may be the bug I am coming across where I am getting a 204 even tho I am setting the status. I've been using the Jersey that comes with the NetBeans 6.1 plugin. I think I asked this before but I don't recall seeing any response... Jersey seems to add about 8MB of dependencies. Do I need all of those in my WAR file? In the properties/libraries pane, when I edit the jersey library, it shows:

jsr311-api.jar, jersey.jar, asm-3.1.jar, comresrcgen.jar, grizzly-http-webserver-1.7.2.jar, http.jar, jdom-1.0.jar, jettison-1.0.RC1.jar, jsp-api-2.0-20040521.jar, persistence-api-1.0.jar, rome-0.9.jar, and wadl2java.jar.

Are all of these required for jersey to work on the web side? I know I took a couple out once, and when I deployed, it broke. So I put them all back.

Thanks again Paul. Appreciate the help.