com.arsdigita.util.servlet
Class Cookies

java.lang.Object
  extended bycom.arsdigita.util.servlet.Cookies

public class Cookies
extends Object

Static convenience methods for dealing with cookies. http://wp.netscape.com/newsref/std/cookie_spec.html http://www.faqs.org/rfcs/rfc2109.html

Version:
$Id: //core-platform/dev/src/com/arsdigita/util/servlet/Cookies.java#5 $
Author:
Justin Ross <jross@redhat.com>
See Also:
HttpServletRequest.getCookies()

Field Summary
static String versionId
           
 
Method Summary
static void delete(javax.servlet.http.HttpServletResponse sresp, String name)
          Deletes the named cookie by setting its maximum age to 0.
static javax.servlet.http.Cookie get(javax.servlet.http.HttpServletRequest sreq, String name)
          Gets the cookie whose name is name from the request.
static String getValue(javax.servlet.http.HttpServletRequest sreq, String name)
          Gets the String value of a cookie with name from the request object sreq.
static javax.servlet.http.Cookie set(javax.servlet.http.HttpServletResponse sresp, String name, String value)
          Sets a session cookie on the response.
static javax.servlet.http.Cookie set(javax.servlet.http.HttpServletResponse sresp, String name, String value, int expiry)
          Sets a cookie on the response with the given expiration time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Method Detail

get

public static final javax.servlet.http.Cookie get(javax.servlet.http.HttpServletRequest sreq,
                                                  String name)
Gets the cookie whose name is name from the request. If there is no such cookie, we return null.

Parameters:
sreq - The request from which to fetch the cookie
name - The String key to use to look up the cookie
Returns:
The Cookie whose name is name or null if there is no such cookie

getValue

public static final String getValue(javax.servlet.http.HttpServletRequest sreq,
                                    String name)
Gets the String value of a cookie with name from the request object sreq. If there is no such cookie, null is returned.

Parameters:
sreq - The request object
name - The String name of the cookie to look for
Returns:
The String value of the cookie or null if it is not present on sreq

set

public static final javax.servlet.http.Cookie set(javax.servlet.http.HttpServletResponse sresp,
                                                  String name,
                                                  String value,
                                                  int expiry)
Sets a cookie on the response with the given expiration time. This method generates a cookie with the defaults of Cookie.Cookie(String, String). The cookie object is returned to allow custom settings.

Parameters:
sresp - The response object
name - The String name of the cookie to set
value - The String value of the cookie to set
Returns:
The Cookie instance created and set by this method

set

public static final javax.servlet.http.Cookie set(javax.servlet.http.HttpServletResponse sresp,
                                                  String name,
                                                  String value)
Sets a session cookie on the response. This method generates a cookie with the defaults of Cookie.Cookie(String, String). The cookie object is returned to allow custom settings.

Parameters:
sresp - The response object
name - The String name of the cookie to set
value - The String value of the cookie to set
Returns:
The Cookie instance created and set by this method

delete

public static final void delete(javax.servlet.http.HttpServletResponse sresp,
                                String name)
Deletes the named cookie by setting its maximum age to 0.

Parameters:
sresp - The response object
name - The String name of the cookie to delete


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC