17 October 2010
0 Servlet Cookie API in Java
Servlet Cookie API in Java
HttpServletInterface.getCookie() method is used to retrieve an array of cookies from the request object.The cookie is the data sent as a part of the request object by the client.
The client sends only the cookie name and cookie value.
Cookie Constructor of Servlet Cookie API
Cookie(java.lang.String name, java.lang.String value) - Constructs a cookie with a specified name and value.Methods of Servlet Cookie API
- java.lang.Object clone(): Overrides the standard java.lang.Object.clone method to return a copy of this cookie.
- java.lang.String getComment(): Returns the comment describing the purpose of this cookie, or null if the cookie has no comment.
- java.lang.String getDomain(): Returns the domain name set for this cookie.
- Int getMaxAge() : Returns the maximum age of the cookie, specified in seconds, By default, -1 indicating the cookie will persist until browser shutdown.
- java.lang.String getName() : Returns the name of the cookie.
- java.lang.String getPath()
- java.lang.String getValue
- int getVersion()
- void setComment(java.lang.String purpose)
- void setDomain(java.lang.String pattern)
- void setMaxAge(int expiry)
- void setValue(java.lang.String newValue)
- void setVersion (int version)
API to add cookie in the Responce header
HttpServletResponseMethod:- void addCookie(Cookie cookie)
API to Read cookie from the client
HttpServletRequestMethod:- Cookies[] getCookies()
Subscribe to:
Post Comments (Atom)
0 comments:
Please give your valuable comments.