java.net
Class CookieHandler

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.net.CookieHandler

public abstract class CookieHandler
extends Object sample code for java.lang.Object definition code for java.lang.Object

A CookieHandler object provides a callback mechanism to hook up a HTTP state management policy implementation into the HTTP protocol handler. The HTTP state management mechanism specifies a way to create a stateful session with HTTP requests and responses.

A system-wide CookieHandler that to used by the HTTP protocol handler can be registered by doing a CookieHandler.setDefault(CookieHandler). The currently registered CookieHandler can be retrieved by calling CookieHandler.getDefault(). For more information on HTTP state management, see RFC 2965: HTTP State Management Mechanism

Since:
1.5

Constructor Summary
CookieHandler sample code for java.net.CookieHandler.CookieHandler() definition code for java.net.CookieHandler.CookieHandler() ()
           
 
Method Summary
abstract  Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,List sample code for java.util.List definition code for java.util.List <String sample code for java.lang.String definition code for java.lang.String >> get sample code for java.net.CookieHandler.get(java.net.URI, java.util.Map) definition code for java.net.CookieHandler.get(java.net.URI, java.util.Map) (URI sample code for java.net.URI definition code for java.net.URI  uri, Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,List sample code for java.util.List definition code for java.util.List <String sample code for java.lang.String definition code for java.lang.String >> requestHeaders)
          Gets all the applicable cookies from a cookie cache for the specified uri in the request header.
static CookieHandler sample code for java.net.CookieHandler definition code for java.net.CookieHandler getDefault sample code for java.net.CookieHandler.getDefault() definition code for java.net.CookieHandler.getDefault() ()
          Gets the system-wide cookie handler.
abstract  void put sample code for java.net.CookieHandler.put(java.net.URI, java.util.Map) definition code for java.net.CookieHandler.put(java.net.URI, java.util.Map) (URI sample code for java.net.URI definition code for java.net.URI  uri, Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,List sample code for java.util.List definition code for java.util.List <String sample code for java.lang.String definition code for java.lang.String >> responseHeaders)
          Sets all the applicable cookies, examples are response header fields that are named Set-Cookie2, present in the response headers into a cookie cache.
static void setDefault sample code for java.net.CookieHandler.setDefault(java.net.CookieHandler) definition code for java.net.CookieHandler.setDefault(java.net.CookieHandler) (CookieHandler sample code for java.net.CookieHandler definition code for java.net.CookieHandler  cHandler)
          Sets (or unsets) the system-wide cookie handler.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

CookieHandler sample code for java.net.CookieHandler() definition code for java.net.CookieHandler()

public CookieHandler()
Method Detail

getDefault sample code for java.net.CookieHandler.getDefault() definition code for java.net.CookieHandler.getDefault()

public static CookieHandler sample code for java.net.CookieHandler definition code for java.net.CookieHandler  getDefault()
Gets the system-wide cookie handler.

Returns:
the system-wide cookie handler; A null return means there is no system-wide cookie handler currently set.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager has been installed and it denies NetPermission sample code for java.net.NetPermission definition code for java.net.NetPermission ("getCookieHandler")
See Also:
setDefault(CookieHandler) sample code for java.net.CookieHandler.setDefault(java.net.CookieHandler) definition code for java.net.CookieHandler.setDefault(java.net.CookieHandler)

setDefault sample code for java.net.CookieHandler.setDefault(java.net.CookieHandler) definition code for java.net.CookieHandler.setDefault(java.net.CookieHandler)

public static void setDefault(CookieHandler sample code for java.net.CookieHandler definition code for java.net.CookieHandler  cHandler)
Sets (or unsets) the system-wide cookie handler. Note: non-standard http protocol handlers may ignore this setting.

Parameters:
cHandler - The HTTP cookie handler, or null to unset.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager has been installed and it denies NetPermission sample code for java.net.NetPermission definition code for java.net.NetPermission ("setCookieHandler")
See Also:
getDefault() sample code for java.net.CookieHandler.getDefault() definition code for java.net.CookieHandler.getDefault()

get sample code for java.net.CookieHandler.get(java.net.URI, java.util.Map<java.lang.String, java.util.List<java.lang.String>>) definition code for java.net.CookieHandler.get(java.net.URI, java.util.Map<java.lang.String, java.util.List<java.lang.String>>)

public abstract Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,List sample code for java.util.List definition code for java.util.List <String sample code for java.lang.String definition code for java.lang.String >> get(URI sample code for java.net.URI definition code for java.net.URI  uri,
                                             Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,List sample code for java.util.List definition code for java.util.List <String sample code for java.lang.String definition code for java.lang.String >> requestHeaders)
                                      throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Gets all the applicable cookies from a cookie cache for the specified uri in the request header. HTTP protocol implementers should make sure that this method is called after all request headers related to choosing cookies are added, and before the request is sent.

Parameters:
uri - a URI to send cookies to in a request
requestHeaders - - a Map from request header field names to lists of field values representing the current request headers
Returns:
an immutable map from state management headers, with field names "Cookie" or "Cookie2" to a list of cookies containing state information
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if an I/O * error occurs
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if either argument is null
See Also:
put(URI, Map) sample code for java.net.CookieHandler.put(java.net.URI, java.util.Map) definition code for java.net.CookieHandler.put(java.net.URI, java.util.Map)

put sample code for java.net.CookieHandler.put(java.net.URI, java.util.Map<java.lang.String, java.util.List<java.lang.String>>) definition code for java.net.CookieHandler.put(java.net.URI, java.util.Map<java.lang.String, java.util.List<java.lang.String>>)

public abstract void put(URI sample code for java.net.URI definition code for java.net.URI  uri,
                         Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,List sample code for java.util.List definition code for java.util.List <String sample code for java.lang.String definition code for java.lang.String >> responseHeaders)
                  throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Sets all the applicable cookies, examples are response header fields that are named Set-Cookie2, present in the response headers into a cookie cache.

Parameters:
uri - a URI where the cookies come from
responseHeaders - an immutable map from field names to lists of field values representing the response header fields returned
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if an I/O error occurs
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if either argument is null
See Also:
get(URI, Map) sample code for java.net.CookieHandler.get(java.net.URI, java.util.Map) definition code for java.net.CookieHandler.get(java.net.URI, java.util.Map)