public class Test {

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

        DefaultHttpClient httpclient = new DefaultHttpClient();
try { HttpPost httpost = new HttpPost("http://localhost:8080/task/index.jsp"); List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("IDToken1", "username"));
nvps.add(new BasicNameValuePair("IDToken2", "password")); httpost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); HttpResponse response = httpclient.execute(httpost);
HttpEntity entity = response.getEntity(); System.out.println("Login form get: " + response.getStatusLine());
EntityUtils.consume(entity); System.out.println("Post logon cookies:");
List<Cookie> cookies = httpclient.getCookieStore().getCookies();
if (cookies.isEmpty()) {
System.out.println("None");
} else {
for (int i = 0; i < cookies.size(); i++) {
System.out.println("- " + cookies.get(i).toString());
}
}
} finally {
httpclient.getConnectionManager().shutdown();
}
} }

最新文章

  1. Python *与** 参数问题
  2. 如何让老式浏览器支持html5新增的语义元素
  3. cookie与session的爱恨情仇
  4. C#调用杀毒软件MSE扫描指定目录或文件
  5. 在linux中使用phpize安装php扩展模块
  6. Oracle中删除重复的经典方案
  7. hadoop拾遗(一)---- 避免切分map文件
  8. 插入三层treeview代码
  9. Java 计算两个日期相差月数
  10. 先学习Oracle 11g的Automatic Diagnostic Repository新功能
  11. gulp入门详细教程
  12. 【NOIP 2017】逛公园
  13. 序号生成算法odoo
  14. 跟未名学Office - PPT核心:表达
  15. MongoDB的Invalid credentials for database
  16. 铺音out2
  17. 安装R语言的包的方法
  18. Integer与int的种种比较你知道多少
  19. TCGA数据批量下载
  20. Ubuntu 开启telnet、ftp服务

热门文章

  1. 【LeetCode】144. Binary Tree Preorder Traversal (3 solutions)
  2. javascript中function和object的区别,以及javascript如何实现面向对象的编程思想.
  3. OGG_GoldenGate数据控制进程Manager(案例)
  4. 文件描述符file descriptor与inode的相关知识
  5. &amp;lt;&amp;lt;Python基础教程&amp;gt;&amp;gt;学习笔记 | 第10章 | 充电时刻
  6. kubernetes 二
  7. USB的中断说明
  8. appserv - 最简单的绑定路径
  9. 【Android】3.8 定位图层展示
  10. node-inspector调试报错问题处理