我知道一个jsessionid,那么如何找到匹配的session,就是说如何调用原session而不是新生成一个session?
first.jsp
<html><body scroll="no" background="<%=request.getContextPath()%>/login/registeredUser/USA/loginBGLine.jpg">
<% out.println(session.getId());
session.setAttribute("test","sessionTest");
%>
<a href="testSession.jsp" >link to testSession</a>
</body>
</html>
testSession.jsp
<html>
<body scroll="no" background="<%=request.getContextPath()%>/login/registeredUser/USA/loginBGLine.jpg">
<% out.println(session.getId());
//HttpSession s = new HttpSession(); out.println("tesst="+session.getAttribute("test"));
out.println("request.isRequestedSessionIdFromURL()="+request.isRequestedSessionIdFromURL()); 
%>
</body>
</html>我通过first.jsp访问testSession.jsp就能得到数据。
假设我通过这样的方式访问了一次以后,我重新开启浏览器,这时候也知道了jseesionid,那我如何取得相应数据呢?

解决方案 »

  1.   

    HttpSessionContext  SessCon=  request.getSession(false).getSessionContext();  
    HttpSession  Sess  =  SessCon.getSession(SessionId);  
      

  2.   

    这个使用IE是不行的,必须使用特殊的工具,来提交一个自定义的HTTP数据包
      

  3.   

    session是使用threadlocal保护的变量,如果你当前所在的线程不属于所找session的线程,是不能获取该session的。
      

  4.   

    在这个session还没有过期或invaildate前,你可以在新开的IE中,调用JavaScript修改cookiedocument.cookie = 'JSESSIONID=' + cookieid;
    这样这个IE之后的访问就会自动使用此前的Session
      

  5.   

    谢谢ChDw(米)
    这种方法有时候可以,有时候又不行
    我这样 试了试 testSession.jsp;jsessionid=*******************
    好像可以