Java Reference
In-Depth Information
code of the ResponseBuilder is automatically initialized with 200. Using the Respon-
seBuilder.language() method, we then set the Content-Language header to French. We
then use the ResponseBuilder.header() method to set a custom response header. Finally,
we create and return the Response object using the ResponseBuilder.build() method.
One interesting thing to note about this code is that we never set the Content-Type of the re-
sponse. Because we have already specified an @Produces annotation, the JAX-RS runtime
will set the media type of the response for us.
Returning Cookies
JAX-RS also provides a simple class to represent new cookie values. This class is
javax.ws.rs.core.NewCookie :
public
public class
class NewCookie
NewCookie extends
extends Cookie {
public
public static
static final
final int
int DEFAULT_MAX_AGE = 1 ;
public
public NewCookie ( String name , String value ) {}
public
public NewCookie ( String name , String value , String path ,
String domain , String comment ,
int
int maxAge , boolean
boolean secure ) {}
public
public NewCookie ( String name , String value , String path ,
String domain , int
int version , String comment ,
int
int maxAge , boolean
boolean secure ) {}
public
public NewCookie ( Cookie cookie ) {}
public
public NewCookie ( Cookie cookie , String comment ,
int
int maxAge , boolean
boolean secure ) {}
public
public static
static NewCookie valueOf ( String value )
throws
throws IllegalArgumentException {}
public
public String getComment () {}
public
public int
int getMaxAge () {}
public
public boolean
boolean isSecure () {}
public
public Cookie toCookie () {}
}
Search WWH ::




Custom Search