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失效,知道如何解决的大哥说说 谢谢了!

解决方案 »

  1.   

    跳转当然没问题,不同webProject之间的session是不共享的,当然会取不到。
    如果想要共享session仅仅是为了共享置于session中的客户登录信息,那么可以用cookies解决这个问题,否则楼主就得研究下自己所使用的web容器该如何配置不同服务的session共享。
      

  2.   

    cookies共享还得是同域下
    如果是调用weService的话,用xfire试试,myeclipse自代的 
      

  3.   

    session失效是肯定的,不同的应用之间session不通用