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()?java.lang.Object.clone?method to return a copy of this cookie. 返回cookie克隆的副本,这个方法覆盖了java.lang.Object.clone()方法。?java.lang.StringgetComment()?null?if the cookie has no comment.返回一个描述cookie用途的注释,如果没有注释,则返回null。?java.lang.StringgetDomain()??intgetMaxAge()?-1?indicating the cookie will persist until browser shutdown. 返回cookie在客户端最大的有效时间,以秒为单位。默认情况下为-1,表示cookie将一直有效直到浏览器关闭。?java.lang.StringgetName()??java.lang.StringgetPath()??booleangetSecure()?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()??intgetVersion()??voidsetComment(java.lang.String?purpose)??voidsetDomain(java.lang.String?pattern)??voidsetMaxAge(int?expiry)??voidsetPath(java.lang.String?uri)??voidsetSecure(boolean?flag)??voidsetValue(java.lang.String?newValue)??voidsetVersion(int?v)?