public class CookieParser extends Object
It is used like this:
CookieParser parser = new CookieParser(req);
float ratio = parser.getFloatCookie("ratio", 1.0);
int count = 0;
try {
count = parser.getIntCookie("count");
}
catch (NumberFormatException e) {
handleMalformedCount();
}
catch (CookieNotFoundException e) {
handleNoCount();
}
CookieNotFoundException| 构造器和说明 |
|---|
CookieParser(javax.servlet.http.HttpServletRequest req)
Constructs a new CookieParser to handle the cookies of the
given request.
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
getBooleanCookie(String name)
Gets the named cookie value as a boolean
|
boolean |
getBooleanCookie(String name,
boolean def)
Gets the named cookie value as a boolean, with a default.
|
byte |
getByteCookie(String name)
Gets the named cookie value as a byte
|
byte |
getByteCookie(String name,
byte def)
Gets the named cookie value as a byte, with a default.
|
char |
getCharCookie(String name)
Gets the named cookie value as a char
|
char |
getCharCookie(String name,
char def)
Gets the named cookie value as a char, with a default.
|
double |
getDoubleCookie(String name)
Gets the named cookie value as a double
|
double |
getDoubleCookie(String name,
double def)
Gets the named cookie value as a double, with a default.
|
float |
getFloatCookie(String name)
Gets the named cookie value as a float
|
float |
getFloatCookie(String name,
float def)
Gets the named cookie value as a float, with a default.
|
int |
getIntCookie(String name)
Gets the named cookie value as a int
|
int |
getIntCookie(String name,
int def)
Gets the named cookie value as a int, with a default.
|
long |
getLongCookie(String name)
Gets the named cookie value as a long
|
long |
getLongCookie(String name,
long def)
Gets the named cookie value as a long, with a default.
|
short |
getShortCookie(String name)
Gets the named cookie value as a short
|
short |
getShortCookie(String name,
short def)
Gets the named cookie value as a short, with a default.
|
String |
getStringCookie(String name)
Gets the named cookie value as a String
|
String |
getStringCookie(String name,
String def)
Gets the named cookie value as a String, with a default.
|
public CookieParser(javax.servlet.http.HttpServletRequest req)
req - the servlet requestpublic String getStringCookie(String name) throws CookieNotFoundException
name - the cookie nameCookieNotFoundException - if the cookie was not foundpublic String getStringCookie(String name, String def)
name - the cookie namedef - the default cookie valuepublic boolean getBooleanCookie(String name) throws CookieNotFoundException
name - the cookie nameCookieNotFoundException - if the cookie was not foundpublic boolean getBooleanCookie(String name, boolean def)
name - the cookie namedef - the default cookie valuepublic byte getByteCookie(String name) throws CookieNotFoundException, NumberFormatException
name - the cookie nameCookieNotFoundException - if the cookie was not foundNumberFormatException - if the cookie value could not
be converted to a bytepublic byte getByteCookie(String name, byte def)
name - the cookie namedef - the default cookie valuepublic char getCharCookie(String name) throws CookieNotFoundException
name - the cookie nameCookieNotFoundException - if the cookie was not foundpublic char getCharCookie(String name, char def)
name - the cookie namedef - the default cookie valuepublic double getDoubleCookie(String name) throws CookieNotFoundException, NumberFormatException
name - the cookie nameCookieNotFoundException - if the cookie was not foundNumberFormatException - if the cookie could not be converted
to a doublepublic double getDoubleCookie(String name, double def)
name - the cookie namedef - the default cookie valuepublic float getFloatCookie(String name) throws CookieNotFoundException, NumberFormatException
name - the cookie nameCookieNotFoundException - if the cookie was not foundNumberFormatException - if the cookie could not be converted
to a floatpublic float getFloatCookie(String name, float def)
name - the cookie namedef - the default cookie valuepublic int getIntCookie(String name) throws CookieNotFoundException, NumberFormatException
name - the cookie nameCookieNotFoundException - if the cookie was not foundNumberFormatException - if the cookie could not be converted
to a intpublic int getIntCookie(String name, int def)
name - the cookie namedef - the default cookie valuepublic long getLongCookie(String name) throws CookieNotFoundException, NumberFormatException
name - the cookie nameCookieNotFoundException - if the cookie was not foundNumberFormatException - if the cookie could not be converted
to a longpublic long getLongCookie(String name, long def)
name - the cookie namedef - the default cookie valuepublic short getShortCookie(String name) throws CookieNotFoundException, NumberFormatException
name - the cookie nameCookieNotFoundException - if the cookie was not foundNumberFormatException - if the cookie could not be converted
to a shortpublic short getShortCookie(String name, short def)
name - the cookie namedef - the default cookie valueCopyright © 2022. All rights reserved.