Package org.zefer.cache
Class CookieManager
- java.lang.Object
-
- org.zefer.cache.CookieManager
-
public class CookieManager extends 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
Constructors Constructor Description CookieManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCookie(String name, String value)static voidmain(String[] args)voidsetCookies(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.voidstoreCookies(URLConnection conn)Retrieves and stores cookies returned by the host on the other side of the the open java.net.URLConnection.StringtoString()Returns a string representation of stored cookies organized by domain.
-
-
-
Method Detail
-
storeCookies
public void storeCookies(URLConnection conn) throws 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:
IOException- Thrown if conn is not open.
-
setCookies
public void setCookies(URLConnection conn) throws 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:
IOException- Thrown if conn has already been opened.
-
toString
public String toString()
Returns a string representation of stored cookies organized by domain.
-
main
public static void main(String[] args)
-
-