users@jersey.java.net

ResponseBuilder and Response questions

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Thu, 26 Jun 2008 19:27:14 -0700 (PDT)

Hey all,

So per another question/answer I had here, I am now returning Response instead of String for my GET method. When returning a String, it seemed that the String was the entire response that came back. Using a basic URLConnection to make the call, I basically read the input stream into a String and that was the same String value I returned. I could get the status code as well. But in my Resource code, I need to do some things that may need to set the status of a response to different values (not authorized, no content, ok, server error, etc). So by using the ResponseBuilder and returning the .build() output, I am able to set the status to what I want. Where I am confused tho, is that my GET sets the "body" header with the xml I return. But, on my calling side, the result is status code 204 (no content), even tho I can grab the "body" header and still get the string out. I did set that status to Response.Status.ok as well, and yet the output code still shows
 204.. unless ok == 204? I am fine if this is the way it should be.. I can grab the String returned via the body header just fine. I just want to make sure, since my API will be a public one, that this is correct or not.

Thanks.