Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.util
Class CookieGenerator

    java.lang.Object
      org.springframework.web.util.CookieGenerator

Direct Known Subclasses:
  CookieLocaleResolver, CookieThemeResolver

    public class CookieGenerator

extends java.lang.Object

Helper class for cookie generation, carrying cookie descriptor settings as bean properties and being able to add and remove cookie to/from a given response.

Can serve as base class for components that generate specific cookies, like CookieLocaleResolcer and CookieThemeResolver.

Since:
  1.1.4
Author:
  Juergen Hoeller
See Also:
  `addCookie(javax.servlet.http.HttpServletResponse, java.lang.String)`, `removeCookie(javax.servlet.http.HttpServletResponse)`, `CookieLocaleResolver`, `CookieThemeResolver`

Field Summary
`static int` | `DEFAULT_COOKIE_MAX_AGE` Deprecated. in favor of setting no max age value at all in such a case
`static java.lang.String` | `DEFAULT_COOKIE_PATH` Default path that cookies will be visible to: "/", i.e.
`protected org.apache.commons.logging.Log` | `logger`

Constructor Summary
`CookieGenerator()`

Method Summary
`void` | `addCookie(javax.servlet.http.HttpServletResponse response, java.lang.String cookieValue)` Add a cookie with the given value to the response, using the cookie descriptor settings of this generator.
`protected javax.servlet.http.Cookie` | `createCookie(java.lang.String cookieValue)` Create a cookie with the given value, using the cookie descriptor settings of this generator (except for "cookieMaxAge").
`java.lang.String` | `getCookieDomain()` Return the domain for cookies created by this generator, if any.
`java.lang.Integer` | `getCookieMaxAge()` Return the maximum age for cookies created by this generator.
`java.lang.String` | `getCookieName()` Return the given name for cookies created by this generator.
`java.lang.String` | `getCookiePath()` Return the path for cookies created by this generator.
`boolean` | `isCookieSecure()` Return whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).
`void` | `removeCookie(javax.servlet.http.HttpServletResponse response)` Remove the cookie that this generator describes from the response.
`void` | `setCookieDomain(java.lang.String cookieDomain)` Use the given domain for cookies created by this generator.
`void` | `setCookieMaxAge(java.lang.Integer cookieMaxAge)` Use the given maximum age (in seconds) for cookies created by this generator.
`void` | `setCookieName(java.lang.String cookieName)` Use the given name for cookies created by this generator.
`void` | `setCookiePath(java.lang.String cookiePath)` Use the given path for cookies created by this generator.
`void` | `setCookieSecure(boolean cookieSecure)` Set whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_COOKIE_PATH

    public static final java.lang.String DEFAULT_COOKIE_PATH

  Default path that cookies will be visible to: "/", i.e. the entire server.

  See Also:
    Constant Field Values

### DEFAULT_COOKIE_MAX_AGE

    @Deprecated
    public static final int DEFAULT_COOKIE_MAX_AGE

  Deprecated. in favor of setting no max age value at all in such a case
  Default maximum age of cookies: maximum integer value, i.e. forever.

  See Also:
    Constant Field Values

### logger

    protected final org.apache.commons.logging.Log logger

Constructor Detail

### CookieGenerator

    public CookieGenerator()

Method Detail

### setCookieName

    public void setCookieName(java.lang.String cookieName)

  Use the given name for cookies created by this generator.

### getCookieName

    public java.lang.String getCookieName()

  Return the given name for cookies created by this generator.

### setCookieDomain

    public void setCookieDomain(java.lang.String cookieDomain)

  Use the given domain for cookies created by this generator. The cookie is only visible to servers in this domain.

### getCookieDomain

    public java.lang.String getCookieDomain()

  Return the domain for cookies created by this generator, if any.

### setCookiePath

    public void setCookiePath(java.lang.String cookiePath)

  Use the given path for cookies created by this generator. The cookie is only visible to URLs in this path and below.

### getCookiePath

    public java.lang.String getCookiePath()

  Return the path for cookies created by this generator.

### setCookieMaxAge

    public void setCookieMaxAge(java.lang.Integer cookieMaxAge)

  Use the given maximum age (in seconds) for cookies created by this generator. Useful special value: -1 ... not persistent, deleted when client shuts down

### getCookieMaxAge

    public java.lang.Integer getCookieMaxAge()

  Return the maximum age for cookies created by this generator.

### setCookieSecure

    public void setCookieSecure(boolean cookieSecure)

  Set whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL). This is an indication to the receiving browser, not processed by the HTTP server itself. Default is "false".

### isCookieSecure

    public boolean isCookieSecure()

  Return whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).

### addCookie

    public void addCookie(javax.servlet.http.HttpServletResponse response,
                          java.lang.String cookieValue)

  Add a cookie with the given value to the response, using the cookie descriptor settings of this generator.

  Delegates to `createCookie(java.lang.String)` for cookie creation.

  Parameters:
    `response` - the HTTP response to add the cookie to
    `cookieValue` - the value of the cookie to add
  See Also:
    `setCookieName(java.lang.String)`, `setCookieDomain(java.lang.String)`, `setCookiePath(java.lang.String)`, `setCookieMaxAge(java.lang.Integer)`

### removeCookie

    public void removeCookie(javax.servlet.http.HttpServletResponse response)

  Remove the cookie that this generator describes from the response. Will generate a cookie with empty value and max age 0.

  Delegates to `createCookie(java.lang.String)` for cookie creation.

  Parameters:
    `response` - the HTTP response to remove the cookie from
  See Also:
    `setCookieName(java.lang.String)`, `setCookieDomain(java.lang.String)`, `setCookiePath(java.lang.String)`

### createCookie

    protected javax.servlet.http.Cookie createCookie(java.lang.String cookieValue)

  Create a cookie with the given value, using the cookie descriptor settings of this generator (except for "cookieMaxAge").

  Parameters:
    `cookieValue` - the value of the cookie to crate
  Returns:
    the cookie
  See Also:
    `setCookieName(java.lang.String)`, `setCookieDomain(java.lang.String)`, `setCookiePath(java.lang.String)`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD