On Feb 11, 2009, at 5:31 AM, Mattias Jonsson wrote:
>
> In the ExceptionMapper, is it possible to return some information to
> the
> caller and set the status some other than HTTP_OK?
>
> Example: Returning "Couldn't find Foo"
>
> GenericEntity<String> entity = new GenericEntity<String>("Couldn't
> find
> Foo") {};
FYI, you don't need GenericEntity here, you only need that when the
type of the entity is itself generic, e.g. List<String>:
> return Response.ok(entity).build();
>
> As I understand the response code will be HTTP_OK (200)
>
> I would like to set the response code to for example HTTP_NOT_FOUND
> (404)
> and still return the information "Couldn't find Foo".
>
String entity = "Couldn't find Foo";
return Response.status(404).entity(entity).type("text/plain").build();
HTH,
Marc.
---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.