dk.netarkivet.harvester.webinterface
Class CookieUtils

java.lang.Object
  extended by dk.netarkivet.harvester.webinterface.CookieUtils

public class CookieUtils
extends java.lang.Object


Nested Class Summary
static class CookieUtils.Lifespan
          Some cookie lifespan to play with.
 
Constructor Summary
CookieUtils()
           
 
Method Summary
static java.lang.String getParameterValue(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          Returns the value of a request parameter, or if not found tries to find a cookie with the same name.
static void setCookie(javax.servlet.http.HttpServletResponse response, java.lang.String name, java.lang.String value)
          Set a cookie on the client, with a default lifespan of @see Lifespan#HOUR
static void setCookie(javax.servlet.http.HttpServletResponse response, java.lang.String name, java.lang.String value, CookieUtils.Lifespan lifeSpan)
          Set a cookie on the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CookieUtils

public CookieUtils()
Method Detail

getParameterValue

public static final java.lang.String getParameterValue(javax.servlet.http.HttpServletRequest request,
                                                       java.lang.String name)
Returns the value of a request parameter, or if not found tries to find a cookie with the same name.

Parameters:
request - the HTTP request
name - the parameter name
Returns:
the value (never null, may be empty)

setCookie

public static final void setCookie(javax.servlet.http.HttpServletResponse response,
                                   java.lang.String name,
                                   java.lang.String value,
                                   CookieUtils.Lifespan lifeSpan)
Set a cookie on the client.

Parameters:
response - the HTTP response wrapper
name - the cookie name
value - the cookie value
lifeSpan - the cookie TTL as an CookieUtils.Lifespan enum value

setCookie

public static final void setCookie(javax.servlet.http.HttpServletResponse response,
                                   java.lang.String name,
                                   java.lang.String value)
Set a cookie on the client, with a default lifespan of @see Lifespan#HOUR

Parameters:
response - the HTTP response wrapper
name - the cookie name
value - the cookie value