JSF+Hibernate+Spring --A
JSP --B
两个系统,A系统制作一个查询功能,点击查询按钮,跳到B系统的一个功能,可以实现吗,谢谢 现在用HttpClient可以实现,但是在跳转过去的时候报错, package com.ccis; import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod; public class LoanTest {
private static final String LOGON_SITE = "http://128.64.96.32:9101/ccis/logon.jsp";
private static final int LOGON_PORT = 80;
private static NameValuePair sessionid;
public static void main(String[] args)throws Exception {
HttpClient client = new HttpClient();
//设置代理
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
//登录页面
PostMethod post = new PostMethod("http://128.64.96.32:9101/ccis/logon.jsp");
NameValuePair username = new NameValuePair("j_username","ccis2wh");
NameValuePair password = new NameValuePair("j_password","ccis");
// NameValuePair loanCardCd = new NameValuePair("loanCardCd","1100000002260786");
// NameValuePair formatReportFlag = new NameValuePair("formatReportFlag", "1");
/* post.setRequestBody(new NameValuePair[] {loanCardCd,formatReportFlag,username, password}); */
post.setRequestBody(new NameValuePair[] {username, password});
//使用POST方式提交数据
sessionid=post.getParameter("SessionID");
int i=client.executeMethod(post);
System.out.println(i);
System.out.println("**************登录*********************");
Cookie[] cookies = client.getState().getCookies();
client.getState().addCookies(cookies);
post.releaseConnection();
System.out.println("*********页面转向************");
String newUrl="http://128.64.96.32:9101/ccis/pages/creditinfor/LoanQuery.jsp";
//测试页面一 登录主页面
PostMethod post1 = new PostMethod(newUrl);
NameValuePair loanCardCd = new NameValuePair("loanCardCd","1100000002260786");
NameValuePair formatReportFlag = new NameValuePair("formatReportFlag", "1");
post.setRequestBody(new NameValuePair[] {loanCardCd, formatReportFlag});
//使用POST方式提交数据
post1.setRequestHeader("Cookie", cookies.toString());
int i1=client.executeMethod(post1);
sessionid=post.getParameter("SessionID");
System.out.println(i1);
String responseString = post1.getResponseBodyAsString();
System.out.println(responseString);
post1.releaseConnection();
}
} ------------------------------------------------------------------------------------------------------
<html> <head> <title>302 Moved Temporarily </title> </head>
<body bgcolor="#FFFFFF">
<p>This document you requested has moved temporarily. </p>
<p>It's now at <a href="http://128.64.96.32:9101/ccis/SessionLose.jsf">http://128.64.96.32:9101/ccis/SessionLose.jsf </a>. </p>
</body> </html> 好像是session失效,知道如何解决的大哥说说 谢谢了!
JSP --B
两个系统,A系统制作一个查询功能,点击查询按钮,跳到B系统的一个功能,可以实现吗,谢谢 现在用HttpClient可以实现,但是在跳转过去的时候报错, package com.ccis; import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod; public class LoanTest {
private static final String LOGON_SITE = "http://128.64.96.32:9101/ccis/logon.jsp";
private static final int LOGON_PORT = 80;
private static NameValuePair sessionid;
public static void main(String[] args)throws Exception {
HttpClient client = new HttpClient();
//设置代理
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
//登录页面
PostMethod post = new PostMethod("http://128.64.96.32:9101/ccis/logon.jsp");
NameValuePair username = new NameValuePair("j_username","ccis2wh");
NameValuePair password = new NameValuePair("j_password","ccis");
// NameValuePair loanCardCd = new NameValuePair("loanCardCd","1100000002260786");
// NameValuePair formatReportFlag = new NameValuePair("formatReportFlag", "1");
/* post.setRequestBody(new NameValuePair[] {loanCardCd,formatReportFlag,username, password}); */
post.setRequestBody(new NameValuePair[] {username, password});
//使用POST方式提交数据
sessionid=post.getParameter("SessionID");
int i=client.executeMethod(post);
System.out.println(i);
System.out.println("**************登录*********************");
Cookie[] cookies = client.getState().getCookies();
client.getState().addCookies(cookies);
post.releaseConnection();
System.out.println("*********页面转向************");
String newUrl="http://128.64.96.32:9101/ccis/pages/creditinfor/LoanQuery.jsp";
//测试页面一 登录主页面
PostMethod post1 = new PostMethod(newUrl);
NameValuePair loanCardCd = new NameValuePair("loanCardCd","1100000002260786");
NameValuePair formatReportFlag = new NameValuePair("formatReportFlag", "1");
post.setRequestBody(new NameValuePair[] {loanCardCd, formatReportFlag});
//使用POST方式提交数据
post1.setRequestHeader("Cookie", cookies.toString());
int i1=client.executeMethod(post1);
sessionid=post.getParameter("SessionID");
System.out.println(i1);
String responseString = post1.getResponseBodyAsString();
System.out.println(responseString);
post1.releaseConnection();
}
} ------------------------------------------------------------------------------------------------------
<html> <head> <title>302 Moved Temporarily </title> </head>
<body bgcolor="#FFFFFF">
<p>This document you requested has moved temporarily. </p>
<p>It's now at <a href="http://128.64.96.32:9101/ccis/SessionLose.jsf">http://128.64.96.32:9101/ccis/SessionLose.jsf </a>. </p>
</body> </html> 好像是session失效,知道如何解决的大哥说说 谢谢了!
解决方案 »
- hibernate关联排序
- 关于<s:iterator>输出标签与js更改标签属性问题.
- 压缩excel问题
- 问题:静态方法和非静态方法的区别
- 关于Webwork时间验证<field-validator type="date">
- 我用eclipse写的一段webservice代码大家帮忙看看。
- 本人想找个JAVA(J2EE方向)的老师。(工作地点在西安的,晚上有时间的)
- 复杂的form表单提交,请求解答.急.....
- 在struts中,如何在iterator标签中显示hibernate一对多关系中set内容?
- 会写触发器的请帮小弟一个忙~~~~
- Java单元测试 JUnit 4.8.1 发布
- 提取网页的概要
如果想要共享session仅仅是为了共享置于session中的客户登录信息,那么可以用cookies解决这个问题,否则楼主就得研究下自己所使用的web容器该如何配置不同服务的session共享。
如果是调用weService的话,用xfire试试,myeclipse自代的