Java Reference
In-Depth Information
Table8-1.Metadata methods available on Response.ResponseBuilder
Method
Description
Abstracts the value of an HTTP Cache-Control response header.
cacheControl(CacheControl
cacheControl)
Sets the content location HTTP header.
contentLocation(java.net.URI
location)
cookie(NewCookie... cookies) Allows you to create a variable-length set of cookies to add to the re-
sponse.
Sets the HTTP Expires header.
expires(java.util.Date ex-
pires)
Allows you to create a custom HTTP header in a key/value pair.
header(java.lang.String
name, java.lang.Object
value)
Sets the Content-Language HTTP header.
language(java.util.Locale
language)
Sets the last modified date on the response.
lastModified(java.util.Date
lastModified)
Usually used to specify the unique URI of a created entity, this sets the
Location header on an HTTP 201 Created response. If a relative URI is
supplied, it will be converted into an absolute URI by resolving it relat-
ive to the base URI of the application. Setting it to null removes any
existing value.
location(java.net.URI loca-
tion)
Sets a value from the Status enumeration representing standard HTTP
status codes, such as OK , BAD_REQUEST , FORBIDDEN ,
INTERNAL_SERVER_ERROR , and so forth.
status(Response.Status
status)
Sets the media type of the response, with enum instances for standard
media types, such as APPLICATION_ATOM_XML , APPLICATION_JSON ,
APPLICATION_OCTET_STREAM , MULTIPART_FORM_DATA , TEXT_HTML ,
TEXT_XML , and more.
type(MediaType type)
Example 8-24 is a quick illustration of how some of these methods can be combined to tailor
your HTTP response.
Example8-24.Metadata service uses Response.ResponseBuilder
package com.soacookbook.rest.metadata;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
Search WWH ::




Custom Search