Example usage for java.net CookieHandler put

List of usage examples for java.net CookieHandler put

Introduction

In this page you can find the example usage for java.net CookieHandler put.

Prototype

public abstract void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException;

Source Link

Document

Sets all the applicable cookies, examples are response header fields that are named Set-Cookie2, present in the response headers into a cookie cache.

Usage

From source file:jdbc.ClientFormLogin.java

public void setCookie(URL url, String value) throws IOException, URISyntaxException {
    CookieHandler handler = CookieHandler.getDefault();
    if (handler != null) {
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        List<String> values = new Vector<String>();
        values.add(value);/*www  .j  a  v a2s  . com*/
        headers.put("Cookie", values);
        handler.put(url.toURI(), headers);
        System.out.println();
    }
}