通过sessionId如何获得session?--------------------------------------
解决方案 »
- iframe 不能刷新
- /petrosyscn/eventdeliver?eventID=11148&basetype=Regional Geology@Report&logid= 解释下这句话~
- 小弟请教:httpclient的问题
- getServletContext
- 急救:在HTML内嵌JScript代码,如何使用XmlNamespaceManager正确读取有命名空间的XML文件
- showModalDialog传值相关问题
- 如何实现,可操作的下拉框???
- servlet和resin问题,急。。。
- 闹鬼了!JSP页面提交汉字乱码的问题
- 一个很初级的jsp问题
- jsp 页面导出excel2003 2007时能自动判断是2003,2007的吗?
- 求助jxl生成excel后另存为怎样实现,谢谢
HttpSession Sess = SessCon.getSession(SessionId);
这个方法,过时了
import java.util.HashMap;public class MySessionContext {
private static MySessionContext instance;
private HashMap mymap; private MySessionContext() {
mymap = new HashMap();
} public static MySessionContext getInstance() {
if (instance == null) {
instance = new MySessionContext();
}
return instance;
} public synchronized void AddSession(HttpSession session) {
if (session != null) {
mymap.put(session.getId(), session);
}
} public synchronized void DelSession(HttpSession session) {
if (session != null) {
mymap.remove(session.getId());
}
} public synchronized HttpSession getSession(String session_id) {
if (session_id == null) return null;
return (HttpSession) mymap.get(session_id);
}} 2.新建一个Session监听 程序代码package cn.org.jshuwei.session.core;import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;public class SessionListener implements HttpSessionListener {
public static Map userMap = new HashMap();
private MySessionContext myc=MySessionContext.getInstance(); public void sessionCreated(HttpSessionEvent httpSessionEvent) {
myc.AddSession(httpSessionEvent.getSession());
} public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
HttpSession session = httpSessionEvent.getSession();
myc.DelSession(session);
}
} 3.在web.xml中配置 程序代码<listener>
<listener-class>cn.org.jshuwei.session.core.SessionListener</listener-class>
</listener> 4.使用 程序代码MySessionContext myc= MySessionContext.getInstance();
HttpSession sess = myc.getSession(sessionId); 来源地址:http://www.jshuwei.org.cn/article.asp?id=398
http://www.sadtojoy.com/aspx/Detail.aspx?id=3697
两个系统间要实现单点登录,在sendRedirect(URL);之后,在跳转的页面里我加了一个filter,可是在filter里确得不到Cookie,request.getCookies();得到的是空。请问各位,该如何在filter里得到Cookie呢?