javax.servlet.http.Cookie 相关
本文转载自:http://lavasoft.blog.51cto.com/62575/78163
?
HttpServletResponse.addCookie(javax.servlet.http.Cookie)?method, which adds fields to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies for each Web server, 300 cookies total, and may limit cookie size to 4 KB each. Sevlet发送cookie使用HttpServletResponse.addCookie(javax.servlet.http.Cookie)方法,一个浏览器预计最多可支持300个cookie,对一个站点最多支持20个cookie,并且可能限制一个cookie的大小不超过4KB。The browser returns cookies to the servlet by adding fields to HTTP request headers. Cookies can be retrieved from a request by using the?HttpServletRequest.getCookies()?method. Several cookies might have the same name but different path attributes. 浏览器通过HTTP请求的处理者返回cookie到一个servlet。cookie能被从HttpServletRequest.getCookies()中重新获取到。Cookies affect the caching of the Web pages that use them. HTTP 1.0 does not cache pages that use cookies created with this class. This class does not support the cache control defined with HTTP 1.1. Cookie影响每一个使用它的web页。 (......)This class supports both the Version 0 (by Netscape) and Version 1 (by RFC 2109) cookie specifications. By default, cookies are created using Version 0 to ensure the best interoperability. 这个类同时支持版本0和版本1的cookie规范。默认情况下,cookie使用版本0来创建以确保最好的交互性。?java.lang.Objectclone()???????????Overrides the standard?
java.lang.Object.clone?method to return a copy of this cookie. 返回cookie克隆的副本,这个方法覆盖了java.lang.Object.clone()方法。?java.lang.StringgetComment()???????????Returns the comment describing the purpose of this cookie, or?
null?if the cookie has no comment.返回一个描述cookie用途的注释,如果没有注释,则返回null。?java.lang.StringgetDomain()???????????Returns the domain name set for this cookie.返回一个cookie域名。(域名指定cookie在哪个域中有效,例如:Domain=.blog.51cto.com)
?intgetMaxAge()???????????Returns the maximum age of the cookie, specified in seconds, By default,?
-1?indicating the cookie will persist until browser shutdown. 返回cookie在客户端最大的有效时间,以秒为单位。默认情况下为-1,表示cookie将一直有效直到浏览器关闭。?java.lang.StringgetName()???????????Returns the name of the cookie.返回cookie的名字。
?java.lang.StringgetPath()???????????Returns the path on the server to which the browser returns this cookie.返回cookie对服务器上哪个url有效。
?booleangetSecure()???????????Returns?
true?if the browser is sending cookies only over a secure protocol, or?false?if the browser can send cookies using any protocol. 如果浏览器仅仅安全协议下发送cookie则返回true。浏览器能使用任何协议发送cookie则返回fasle。?java.lang.StringgetValue()???????????Returns the value of the cookie. 返回cookie的值。
?intgetVersion()???????????Returns the version of the protocol this cookie complies with.返回cookie内容所遵循的版本。(目前只有值为1时可用)。
?voidsetComment(java.lang.String?purpose)???????????Specifies a comment that describes a cookie's purpose.设置描述cookie用途的注释。
?voidsetDomain(java.lang.String?pattern)???????????Specifies the domain within which this cookie should be presented.设置cookie在哪一个域中使用。
?voidsetMaxAge(int?expiry)???????????Sets the maximum age of the cookie in seconds.设置cookie最大的有效时间。
?voidsetPath(java.lang.String?uri)???????????Specifies a path for the cookie to which the client should return the cookie.设置cookie的有效路径。
?voidsetSecure(boolean?flag)???????????Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.设置是否使用安全协议如HTTPS或SSL等发送cookie。
?voidsetValue(java.lang.String?newValue)???????????Assigns a new value to a cookie after the cookie is created. 给一个cookie重新指定一个新值。
?voidsetVersion(int?v)???????????Sets the version of the cookie protocol this cookie complies with.设置cookie使用的协议版本。?