org.hawk.http
Class CookieManager

java.lang.Object
  extended by org.hawk.http.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()); original author Ian Brown... modified by Manoranjan Sahu


Constructor Summary
CookieManager()
           
 
Method Summary
static java.lang.String fetchJSessionID(java.net.URLConnection conn)
           
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getCookie(java.net.URLConnection conn)
          Retrieves and stores cookies returned by the host on the other side of the the open java.net.URLConnection.
static boolean loadCookies(org.apache.commons.httpclient.HttpClient httpClient, HttpSessionInfo httpSessionInfo)
           
static void main(java.lang.String[] args)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CookieManager

public CookieManager()
Method Detail

getCookie

public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getCookie(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.

fetchJSessionID

public static java.lang.String fetchJSessionID(java.net.URLConnection conn)

loadCookies

public static boolean loadCookies(org.apache.commons.httpclient.HttpClient httpClient,
                                  HttpSessionInfo httpSessionInfo)

main

public static void main(java.lang.String[] args)
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.