FileDocCategorySizeDatePackage
CookieExample.javaAPI DocExample1162Sun Dec 05 23:04:20 GMT 2004com.discursive.jccook.httpclient

CookieExample

public class CookieExample extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		HttpClient client = new HttpClient();
	
		System.out.println( "Making Request without Cookie: " );
		makeRequest(client);
			
		System.out.println( "Making Request with Cookie: " );
		Cookie cookie = new Cookie(".discursive.com", "test_cookie", "hello", "/", null, false );
		client.getState().addCookie( cookie );
		makeRequest(client);
	
private static voidmakeRequest(org.apache.commons.httpclient.HttpClient client)

		String url = "http://www.discursive.com/cgi-bin/jccook/cookie_test.cgi";
		HttpMethod method = new GetMethod( url );
		client.executeMethod( method );
		String response = method.getResponseBodyAsString();
		System.out.println( response );
		method.releaseConnection();
		method.recycle();