Package org.apache.wiki.tags
Class CookieTag
- java.lang.Object
-
- javax.servlet.jsp.tagext.TagSupport
-
- org.apache.wiki.tags.CookieTag
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.jsp.tagext.IterationTag
,javax.servlet.jsp.tagext.JspTag
,javax.servlet.jsp.tagext.Tag
public class CookieTag extends javax.servlet.jsp.tagext.TagSupport
Sets or gets Cookie values. This implementation makes the following assumptions:- The cookie contains any number of name-value pairs
- Name-value pairs are separated by "&" in the encoded cookie value string
- An encoded name-value pair is compatible with JavaScript's encodeURIComponent(). Notably, spaces are encoded as "%20".
- A decoded name-value pair separates the name and value with a "="
The value of a cookie carrying values n1="v1" and n2="v2 with space" would thus be
n1%3Dv1&n2%3Dv2%20with%20space
Usage:
<wiki:cookie name="cookiename" var="contextvariable" scope="page" />
- Returns the value of the named cookie, or an empty string if not set. If 'var' is specified, the value is set into a context variable of this name. The 'scope' parameter may be added to specify the context: "session", "page", "request". If var is omitted, the output is placed directly into the JSP page.<wiki:cookie name="cookiename" value="encoded_value" />
- Sets the named cookie to the given value. If the value string is empty, the cookie value is set to empty; otherwise the cookie encoding rules of this class must be followed for the value.<wiki:cookie name="cookiename" item="parameter_name" />
- Assumes that the cookie contains URLEncoded name-value pairs, with name and value separated by an equals sign, and returns the value of the specified item. <wiki:cookie name="cookiename" item="parameter_name" value="value" /> - Sets the value of 'parameter_name' in the named cookie to 'value'.<wiki:cookie name="cookiename" clear="parameter_name" />
- Removes the named parameter from the cookie.<wiki:cookie clear="cookiename" />
- Removes the named cookie. Clear may be used at the same time as a value is retrieved (or set, despite the dubious usefulness of that operation).- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CookieTag()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
doEndTag()
void
release()
void
setClear(java.lang.String s)
Set the "clear" parameter.void
setItem(java.lang.String s)
Set the "item" parameter.void
setName(java.lang.String s)
Set the "name" parameter.void
setScope(java.lang.String s)
Set the "scope" parameter.void
setValue(java.lang.String s)
Set the "value" parameter.void
setVar(java.lang.String s)
Set the "var" parameter.
-
-
-
Constructor Detail
-
CookieTag
public CookieTag()
-
-
Method Detail
-
setName
public void setName(java.lang.String s)
Set the "name" parameter.- Parameters:
s
- The name.
-
setItem
public void setItem(java.lang.String s)
Set the "item" parameter.- Parameters:
s
- The item.
-
setValue
public void setValue(java.lang.String s)
Set the "value" parameter.- Parameters:
s
- The value.
-
setVar
public void setVar(java.lang.String s)
Set the "var" parameter.- Parameters:
s
- The parameter.
-
setClear
public void setClear(java.lang.String s)
Set the "clear" parameter.- Parameters:
s
- The parameter.
-
setScope
public void setScope(java.lang.String s)
Set the "scope" parameter.- Parameters:
s
- The scope.
-
release
public void release()
- Specified by:
release
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
release
in classjavax.servlet.jsp.tagext.TagSupport
-
doEndTag
public int doEndTag()
- Specified by:
doEndTag
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
doEndTag
in classjavax.servlet.jsp.tagext.TagSupport
-
-