org.apache.cocoon.environment
Interface Response

All Known Implementing Classes:
ActionResponse, CommandLineResponse, HttpResponse, PortletResponse, RenderResponse, ResponseWrapper

public interface Response

Defines an interface to provide client response information .

Version:
CVS $Id: Response.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Davanum Srinivas, Carsten Ziegeler

Method Summary
 void addCookie(Cookie cookie)
          Adds the specified cookie to the response.
 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 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.
 

Method Detail

getCharacterEncoding

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.

Returns:
a String specifying the name of the charset, for example, ISO-8859-1

setLocale

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.

Parameters:
loc - the locale of the response
See Also:
getLocale()

getLocale

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

See Also:
setLocale(Locale)

createCookie

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

void addCookie(Cookie cookie)
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

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

Parameters:
name - the header name
Returns:
true if the named response header has already been set; false otherwise

encodeURL

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.

Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.

setDateHeader

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.

Parameters:
name - the name of the header to set
date - the assigned date value
See Also:
containsHeader(String), addDateHeader(String, long)

addDateHeader

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.

Parameters:
name - the name of the header to set
date - the additional date value
See Also:
setDateHeader(String, long)

setHeader

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.

Parameters:
name - the name of the header
value - the header value
See Also:
containsHeader(String), addHeader(String, String)

addHeader

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.

Parameters:
name - the name of the header
value - the additional header value
See Also:
setHeader(String, String)

setIntHeader

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.

Parameters:
name - the name of the header to set
value - the assigned int value
See Also:
containsHeader(String), addIntHeader(String, int)

addIntHeader

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.

Parameters:
name - the name of the header to set
value - the additional int value
See Also:
setIntHeader(String, int)


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.