org.hccp.net
Class CookieManager

java.lang.Object
  |
  +--org.hccp.net.CookieManager

public class CookieManager
extends java.lang.Object

CookieManager is a simple utilty for handling cookies when working with java.net.URL and java.net.URLConnection objects. Cookiemanager cm = new CookieManager(); URL url = new URL("http://www.hccp.org/test/cookieTest.jsp"); . . . // getting cookies: URLConnection conn = url.openConnection(); conn.connect(); // setting cookies cm.storeCookies(conn); cm.setCookies(url.openConnection());


Constructor Summary
CookieManager()
           
 
Method Summary
static void main(java.lang.String[] args)
           
 void setCookies(java.net.URLConnection conn)
          Prior to opening a URLConnection, calling this method will set all unexpired cookies that match the path or subpaths for thi underlying URL The connection MUST NOT have been opened method or an IOException will be thrown.
 void storeCookies(java.net.URLConnection conn)
          Retrieves and stores cookies returned by the host on the other side of the the open java.net.URLConnection.
 java.lang.String toString()
          Returns a string representation of stored cookies organized by domain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CookieManager

public CookieManager()
Method Detail

storeCookies

public void storeCookies(java.net.URLConnection conn)
                  throws java.io.IOException
Retrieves and stores cookies returned by the host on the other side of the the open java.net.URLConnection. The connection MUST have been opened using the connect() method or a IOException will be thrown.

Parameters:
conn - a java.net.URLConnection - must be open, or IOException will be thrown
Throws:
java.io.IOException - Thrown if conn is not open.

setCookies

public void setCookies(java.net.URLConnection conn)
                throws java.io.IOException
Prior to opening a URLConnection, calling this method will set all unexpired cookies that match the path or subpaths for thi underlying URL The connection MUST NOT have been opened method or an IOException will be thrown.

Parameters:
conn - a java.net.URLConnection - must NOT be open, or IOException will be thrown
Throws:
java.io.IOException - Thrown if conn has already been opened.

toString

public java.lang.String toString()
Returns a string representation of stored cookies organized by domain.

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)