Hi David, In our organization, we return a Response object with our own entity and explicitly set the response code. It doesn't look as if MessageBodyWriter exposes a way to set the response code (by that time, it's probably too late - I haven't confirmed this in the source code though). Even inside an ExceptionMapper, you need to return a Response object if you want to set both the entity and response code at the same time.
Regards, kl On Mon, Dec 19, 2011 at 10:05 AM, KARR, DAVID <[email protected]> wrote: > In my relatively simple JAX-RS services, I return a Java object that's > serialized to XML or JSON. I typically don't set the HTTP status code. If > I remember correctly, if instead of just returning my Java object, I use a > pure "javax.ws.rs.core.Response" object I can set the status code, and set > the "entity" to the Java object I want to serialize. As far as I can tell, > I can't set the status code if I just return a java object. What is the > best strategy for returning an object AND setting the status code? Is it > just using the "Response" object as I described? > > -------------- > David M. Karr > Senior Technical Architect, CDE Web Architecture > ATT Consumer Digital Experience > (425) 288-6027 work > (206) 909-0664 cell > > This e-mail, and any attachments, are intended only for use by the > addressee(s) named herein and may contain legally privileged and/or > confidential information. It is the property of AT&T. If you are not the > intended recipient of this email, you are hereby notified that any > dissemination, distribution or copying of this email, any attachments > thereto, and any use of the information contained is strictly prohibited. > If you have received this email in error, please notify me at 425-288-6027and > permanently delete the original and any copy thereof. > > >
