Java Doc for Cookie.java in  » EJB-Server-resin-3.1.5 » jsdk » javax » servlet » http » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server resin 3.1.5 » jsdk » javax.servlet.http 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.servlet.http.Cookie

Cookie
public class Cookie implements Cloneable(Code)
Encapsulates HTTP cookies.

Cookies are use to keep track of users for sessions and to recognize users back for personalization.

When deleting cookies or changing the time, it's important to set the same domain and path as originally passed. Browsers distinguish cookies with different domain and path.

 Cookie myCookie = new Cookie("mycookie", "myvalue");
 myCookie.setPath("/path");
 myCookie.setDomain("mydom.com");
 // will live for a month
 myCookie.setMaxAge(60 * 24 * 3600);
 response.addCookie(myCookie);
 

To delete the above cookie, you'll need to do something like the following:

 Cookie myCookie = new Cookie("mycookie", "myvalue");
 myCookie.setPath("/path");
 myCookie.setDomain("mydom.com");
 // kill the cookies
 myCookie.setMaxAge(0);
 response.addCookie(myCookie);
 



Constructor Summary
public  Cookie(String name, String value)
     Create a new cookie with the specified name and value.

Method Summary
public  Objectclone()
    
public  StringgetComment()
    
public  StringgetDomain()
    
public  intgetMaxAge()
     Returns the max age of the cookie in seconds.
public  StringgetName()
     Returns the cookie's name.
public  StringgetPath()
     Gets the URL path of a cookie.
public  booleangetSecure()
     Returns true if the cookie must be over a secure connection.
public  StringgetValue()
     Returns the cookie's value.
public  intgetVersion()
     Returns cookie protocol version.
public  voidsetComment(String comment)
    
public  voidsetDomain(String domain)
     Sets the cookie domain.
public  voidsetMaxAge(int maxAge)
     Sets the max age of a cookie.
public  voidsetPath(String path)
     Sets the URL path of a cookie.
public  voidsetSecure(boolean secure)
     Tells the browser that this cookie should only be passed over a secure connection like SSL.
public  voidsetValue(String value)
     Sets the cookie's value.
public  voidsetVersion(int version)
     Sets cookie protocol version, defaulting to 0.
public  StringtoString()
     Converts the cookie to a string for debugging.


Constructor Detail
Cookie
public Cookie(String name, String value)(Code)
Create a new cookie with the specified name and value.
Parameters:
  name - name of the cookie
Parameters:
  value - value of the cookie




Method Detail
clone
public Object clone()(Code)
Returns a clone of the cookie



getComment
public String getComment()(Code)
Gets the cookie comment



getDomain
public String getDomain()(Code)
Returns the cookie's domain



getMaxAge
public int getMaxAge()(Code)
Returns the max age of the cookie in seconds.



getName
public String getName()(Code)
Returns the cookie's name.



getPath
public String getPath()(Code)
Gets the URL path of a cookie.



getSecure
public boolean getSecure()(Code)
Returns true if the cookie must be over a secure connection.



getValue
public String getValue()(Code)
Returns the cookie's value.



getVersion
public int getVersion()(Code)
Returns cookie protocol version.



setComment
public void setComment(String comment)(Code)
Sets the cookie comment
Parameters:
  comment - comment string



setDomain
public void setDomain(String domain)(Code)
Sets the cookie domain. A site which uses multiple machines, e.g. with DNS round robin, but a single site will want to set the domain.
 cookie.setDomain("yahoo.com");
 

Parameters:
  domain - DNS domain name



setMaxAge
public void setMaxAge(int maxAge)(Code)
Sets the max age of a cookie. Setting maxAge to zero deletes the cookie. Setting it to something large makes the cookie persistent. If maxAge is not set, the cookie will only last for the session.
Parameters:
  maxAge - lifetime of the cookie in seconds.



setPath
public void setPath(String path)(Code)
Sets the URL path of a cookie. Normally, cookies will just use the root path.



setSecure
public void setSecure(boolean secure)(Code)
Tells the browser that this cookie should only be passed over a secure connection like SSL.



setValue
public void setValue(String value)(Code)
Sets the cookie's value. Normally this will be a random unique string to lookup the cookie in a database.



setVersion
public void setVersion(int version)(Code)
Sets cookie protocol version, defaulting to 0.



toString
public String toString()(Code)
Converts the cookie to a string for debugging.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.