org.apache.cocoon.environment
Interface Response

All Superinterfaces:
HttpServletResponse, ServletResponse

public interface Response
extends HttpServletResponse

Defines an interface to provide client response information.

Version:
$Id: Response.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
 
Fields inherited from interface javax.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
 
Method Summary
 void addCookie(Cookie cookie)
          Adds the specified cookie to the response.
 void addCookie(Cookie cookie)
          Deprecated. use addCookie(javax.servlet.http.Cookie) instead.
 void addDateHeader(String name, long date)
          Adds a response header with the given name and date-value.
 void addHeader(String name, String value)
          Adds a response header with the given name and value.
 void addIntHeader(String name, int value)
          Adds a response header with the given name and int value.
 boolean containsHeader(String name)
          Returns a boolean indicating whether the named response header has already been set.
 Cookie createCocoonCookie(String name, String value)
          Deprecated. use createCookie(String, String) instead.
 Cookie createCookie(String name, String value)
          Constructs a cookie with a specified name and value.
 String encodeURL(String url)
          Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
 String getCharacterEncoding()
          Returns the name of the charset used for the MIME body sent in this response.
 Locale getLocale()
          Returns the locale assigned to the response.
 void setDateHeader(String name, long date)
          Sets a response header with the given name and date-value.
 void setHeader(String name, String value)
          Sets a response header with the given name and value.
 void setIntHeader(String name, int value)
          Sets a response header with the given name and int value.
 void setLocale(Locale loc)
          Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.
 
Methods inherited from interface javax.servlet.http.HttpServletResponse
encodeRedirectUrl, encodeRedirectURL, encodeUrl, sendError, sendError, sendRedirect, setStatus, setStatus
 
Methods inherited from interface javax.servlet.ServletResponse
flushBuffer, getBufferSize, getContentType, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentType
 

Method Detail

getCharacterEncoding

public String getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this response.

If no charset has been assigned, it is implicitly set to ISO-8859-1 (Latin-1).

See RFC 2047 (http://ds.internic.net/rfc/rfc2045.txt) for more information about character encoding and MIME.

Specified by:
getCharacterEncoding in interface ServletResponse
Returns:
a String specifying the name of the charset, for example, ISO-8859-1

setLocale

public void setLocale(Locale loc)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. By default, the response locale is the default locale for the server.

Specified by:
setLocale in interface ServletResponse
Parameters:
loc - the locale of the response
See Also:
getLocale()

getLocale

public Locale getLocale()
Returns the locale assigned to the response.

Specified by:
getLocale in interface ServletResponse
See Also:
setLocale(Locale)

createCookie

public Cookie createCookie(String name,
                           String value)
Constructs a cookie with a specified name and value.

The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation.

The value can be anything the server chooses to send. Its value is probably of interest only to the server. The cookie's value can be changed after creation with the setValue method.

By default, cookies are created according to the Netscape cookie specification. The version can be changed with the setVersion method.

Parameters:
name - a String specifying the name of the cookie
value - a String specifying the value of the cookie
Throws:
IllegalArgumentException - if the cookie name contains illegal characters (for example, a comma, space, or semicolon) or it is one of the tokens reserved for use by the cookie protocol

addCookie

public void addCookie(Cookie cookie)
Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.

Specified by:
addCookie in interface HttpServletResponse
Parameters:
cookie - the Cookie to return to the client

createCocoonCookie

public Cookie createCocoonCookie(String name,
                                 String value)
Deprecated. use createCookie(String, String) instead.

Constructs a cookie with a specified name and value.

The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation.

The value can be anything the server chooses to send. Its value is probably of interest only to the server. The cookie's value can be changed after creation with the setValue method.

By default, cookies are created according to the Netscape cookie specification. The version can be changed with the setVersion method.

Parameters:
name - a String specifying the name of the cookie
value - a String specifying the value of the cookie
Throws:
IllegalArgumentException - if the cookie name contains illegal characters (for example, a comma, space, or semicolon) or it is one of the tokens reserved for use by the cookie protocol

addCookie

public void addCookie(Cookie cookie)
Deprecated. use addCookie(javax.servlet.http.Cookie) instead.

Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.

Parameters:
cookie - the Cookie to return to the client

containsHeader

public boolean containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set.

Specified by:
containsHeader in interface HttpServletResponse
Parameters:
name - the header name
Returns:
true if the named response header has already been set; false otherwise

encodeURL

public String encodeURL(String url)
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.

For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

Specified by:
encodeURL in interface HttpServletResponse
Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.

setDateHeader

public void setDateHeader(String name,
                          long date)
Sets a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Specified by:
setDateHeader in interface HttpServletResponse
Parameters:
name - the name of the header to set
date - the assigned date value
See Also:
containsHeader(String), addDateHeader(String, long)

addDateHeader

public void addDateHeader(String name,
                          long date)
Adds a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. This method allows response headers to have multiple values.

Specified by:
addDateHeader in interface HttpServletResponse
Parameters:
name - the name of the header to set
date - the additional date value
See Also:
setDateHeader(String, long)

setHeader

public void setHeader(String name,
                      String value)
Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Specified by:
setHeader in interface HttpServletResponse
Parameters:
name - the name of the header
value - the header value
See Also:
containsHeader(String), addHeader(String, String)

addHeader

public void addHeader(String name,
                      String value)
Adds a response header with the given name and value. This method allows response headers to have multiple values.

Specified by:
addHeader in interface HttpServletResponse
Parameters:
name - the name of the header
value - the additional header value
See Also:
setHeader(String, String)

setIntHeader

public void setIntHeader(String name,
                         int value)
Sets a response header with the given name and int value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Specified by:
setIntHeader in interface HttpServletResponse
Parameters:
name - the name of the header to set
value - the assigned int value
See Also:
containsHeader(String), addIntHeader(String, int)

addIntHeader

public void addIntHeader(String name,
                         int value)
Adds a response header with the given name and int value. This method allows response headers to have multiple values.

Specified by:
addIntHeader in interface HttpServletResponse
Parameters:
name - the name of the header to set
value - the additional int value
See Also:
setIntHeader(String, int)


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.