List of usage examples for java.net CookieManager setCookiePolicy
public void setCookiePolicy(CookiePolicy cookiePolicy)
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println(cookie.getCommentURL()); System.out.println();/*from ww w . j a va 2s.c o m*/ } }
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println(cookie.getPortlist()); System.out.println();// w w w . ja v a 2 s.co m } }
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println(cookie.toString()); System.out.println();//from w ww . j a va 2 s. com } }
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println(cookie.getDomain()); System.out.println();/*from ww w .j av a 2 s .c om*/ } }
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println("Name = " + cookie.getName()); System.out.println("Value = " + cookie.getValue()); System.out.println("Lifetime (seconds) = " + cookie.getMaxAge()); System.out.println("Path = " + cookie.getPath()); System.out.println();/*from w ww .j av a 2 s. c om*/ } }
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println("Name = " + cookie.getName()); System.out.println("Value = " + cookie.getValue()); System.out.println("Lifetime (seconds) = " + cookie.getMaxAge()); System.out.println("Path = " + cookie.getPath()); System.out.println();/*ww w .j a va2 s .c o m*/ } }
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_NONE); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println("Name = " + cookie.getName()); System.out.println("Value = " + cookie.getValue()); System.out.println("Lifetime (seconds) = " + cookie.getMaxAge()); System.out.println("Path = " + cookie.getPath()); System.out.println();//from www .j av a2s.c o m } }
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); CookieStore cookieStore = cm.getCookieStore(); List<HttpCookie> cookies = cookieStore.getCookies(); for (HttpCookie cookie : cookies) { System.out.println("Name = " + cookie.getName()); System.out.println("Value = " + cookie.getValue()); System.out.println("Lifetime (seconds) = " + cookie.getMaxAge()); System.out.println("Path = " + cookie.getPath()); System.out.println();//from www . j av a 2s .com } }
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); CookieStore cookieStore = cm.getCookieStore(); List<HttpCookie> cookies = cookieStore.get(new URI("http://google.com")); for (HttpCookie cookie : cookies) { System.out.println("Name = " + cookie.getName()); System.out.println("Value = " + cookie.getValue()); System.out.println("Lifetime (seconds) = " + cookie.getMaxAge()); System.out.println("Path = " + cookie.getPath()); System.out.println();/*www . java 2s .c o m*/ } }
From source file:ListAllCookies.java
public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("usage: java ListAllCookies url"); return;//ww w .j a v a2s . co m } CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); new URL(args[0]).openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println("Name = " + cookie.getName()); System.out.println("Value = " + cookie.getValue()); System.out.println("Lifetime (seconds) = " + cookie.getMaxAge()); System.out.println("Path = " + cookie.getPath()); System.out.println(); } }