Example usage for org.apache.commons.httpclient Cookie isPersistent

List of usage examples for org.apache.commons.httpclient Cookie isPersistent

Introduction

In this page you can find the example usage for org.apache.commons.httpclient Cookie isPersistent.

Prototype

public boolean isPersistent() 

Source Link

Usage

From source file:GetCookiePrintAndSetValue.java

public static void main(String args[]) throws Exception {

    HttpClient client = new HttpClient();
    client.getParams().setParameter("http.useragent", "My Browser");

    GetMethod method = new GetMethod("http://localhost:8080/");
    try {//from   w  ww.  j a va 2  s .c om
        client.executeMethod(method);
        Cookie[] cookies = client.getState().getCookies();
        for (int i = 0; i < cookies.length; i++) {
            Cookie cookie = cookies[i];
            System.err.println("Cookie: " + cookie.getName() + ", Value: " + cookie.getValue()
                    + ", IsPersistent?: " + cookie.isPersistent() + ", Expiry Date: " + cookie.getExpiryDate()
                    + ", Comment: " + cookie.getComment());

            cookie.setValue("My own value");
        }
        client.executeMethod(method);
    } catch (Exception e) {
        System.err.println(e);
    } finally {
        method.releaseConnection();
    }
}