Oracle Application Server 10g HTTPClient API Reference
10g (9.0.4)

B12022-01

HTTPClient
Class Cookie

java.lang.Object
  |
  +--HTTPClient.Cookie
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Cookie2

public class Cookie
extends java.lang.Object
implements java.io.Serializable

This class represents an http cookie as specified in Netscape's cookie spec; however, because not even Netscape follows their own spec, and because very few folks out there actually read specs but instead just look whether Netscape accepts their stuff, the Set-Cookie header field parser actually tries to follow what Netscape has implemented, instead of what the spec says. Additionally, the parser it will also recognize the Max-Age parameter from rfc-2109, as that uses the same header field (Set-Cookie).

Some notes about how Netscape (4.7) parses:

Since:
V0.3
See Also:
Serialized Form

Constructor Summary
Cookie(java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, java.util.Date expires, boolean secure)
          Create a cookie.

 

Method Summary
 boolean discard()
           
 boolean equals(java.lang.Object obj)
          Two cookies match if the name, path and domain match.
 java.util.Date expires()
           
 java.lang.String getDomain()
          Return the domain this cookie is valid in.
 java.lang.String getName()
          Return the name of this cookie.
 java.lang.String getPath()
          Return the path this cookie is associated with.
 java.lang.String getValue()
          Return the value of this cookie.
 boolean hasExpired()
           
 int hashCode()
          Hash up name, path and domain into new hash.
 boolean isSecure()
          Return whether this cookie should only be sent over secure connections.
 java.lang.String toString()
          Create a string containing all the cookie fields.

 

Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait

 

Constructor Detail

Cookie

public Cookie(java.lang.String name,
              java.lang.String value,
              java.lang.String domain,
              java.lang.String path,
              java.util.Date expires,
              boolean secure)
Create a cookie.
Parameters:
name - the cookie name
value - the cookie value
domain - the host this cookie will be sent to
path - the path prefix for which this cookie will be sent
expires - the Date this cookie expires, null if at end of session
secure - if true this cookie will only be over secure connections
Throws:
java.lang.NullPointerException - if name, value, domain, or path is null
Since:
V0.3-1
Method Detail

getName

public java.lang.String getName()
Return the name of this cookie.

getValue

public java.lang.String getValue()
Return the value of this cookie.

expires

public java.util.Date expires()
Returns:
the expiry date of this cookie, or null if none set.

discard

public boolean discard()
Returns:
true if the cookie should be discarded at the end of the session; false otherwise

getDomain

public java.lang.String getDomain()
Return the domain this cookie is valid in.

getPath

public java.lang.String getPath()
Return the path this cookie is associated with.

isSecure

public boolean isSecure()
Return whether this cookie should only be sent over secure connections.

hasExpired

public boolean hasExpired()
Returns:
true if this cookie has expired

hashCode

public int hashCode()
Hash up name, path and domain into new hash.
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Two cookies match if the name, path and domain match.
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Create a string containing all the cookie fields. The format is that used in the Set-Cookie header.
Overrides:
toString in class java.lang.Object

Copyright © 2003 Oracle Corporation. All Rights Reserved.