users@glassfish.java.net
Re: how to send user defined error message in the status ...
This message
: [
Message body
] [ More options (
top
,
bottom
) ]
Related messages
: [
Next message
] [
Previous message
] [
In reply to
] [
Next in thread
] [
Replies
]
Contemporary messages sorted
: [
by date
] [
by thread
] [
by subject
] [
by author
] [
by messages with attachments
]
From
: <
forums_at_java.net
>
Date
: Tue, 12 Apr 2011 03:48:13 -0500 (CDT)
See public static Response.ResponseBuilder status(Response.StatusType status)
in Response class [1]. StatusType [2] has getReasonPhrase() which is what
you want to set to provide custom status message.
[2] states known implementing classes of this static interface are
ClientResponse.Status [3], Response.Status [4]. For example, [4] already
has 200 OK, so you can change it to 200 EXCELLENT with code similar to:
return Response.status(new Response.StatusType() {
@Override
public int getStatusCode() {
return 200;
}
@Override
public Response.Status.Family getFamily() {
return Response.Status.Family.SUCCESSFUL;
}
@Override
public String getReasonPhrase() {
return "EXCELLENT";
}
}).build();
When you do standard http request, first line in response would be
status something like:
200 EXCELLENT
geterrorreason returns "EXCELLENT"
Hopefully this explains what you want to do - to set custom status phrase.
(with thanks to Pavel, who provided pointers)
[1]
http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/core/Response.ResponseBuilder.html#status%28javax.ws.rs.core.Response.StatusType%29
[1]
[2]
http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/core/Response.StatusType.html
[2]
[3]
http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/client/ClientResponse.Status.html
[3]
[4]
http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/core/Response.Status.html
[4]
[1]
http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/core/Response.ResponseBuilder.html#status%28javax.ws.rs.core.Response.StatusType%29
[2]
http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/core/Response.StatusType.html
[3]
http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/client/ClientResponse.Status.html
[4]
http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/core/Response.Status.html
-- [Message sent by forum member 'jbenoit'] View Post:
http://forums.java.net/node/789369
This message
: [
Message body
]
Next message
:
forums_at_java.net: "Re: Glassfish 3.1 is much slower to deploy"
Previous message
:
Andreas Loew: "Re: Glassfish 3.1 is much slower to deploy"
In reply to
:
forums_at_java.net: "Re: how to send user defined error message in the status ..."
Next in thread
:
forums_at_java.net: "Re: how to send user defined error message in the status ..."
Reply
:
forums_at_java.net: "Re: how to send user defined error message in the status ..."
Contemporary messages sorted
: [
by date
] [
by thread
] [
by subject
] [
by author
] [
by messages with attachments
]