一个tomcat下两个项目(ZK项目)共享session
来源:互联网 发布:round robin调度算法 编辑:程序博客网 时间:2024/04/30 01:23
以下内容多个用户登录时,后一个用户的信息会将前一个用户的信息冲掉,因为servletContext是application级别,希望看的本篇博客的人注意,解决方案还未完全完成,过两天再贴。
最后用的是单点登录,CAS认证,网上已有的比较成熟的解决方案。
发送项目为项目C
public void onSetTextbox(){Textbox texb = (Textbox)this.getFellow("texb");SimpleSession s = (SimpleSession) Executions.getCurrent().getDesktop().getSession();HttpSession session = (HttpSession) s.getNativeSession();session.setAttribute("username", texb.getValue());session.setAttribute("password", "qwert");session.setMaxInactiveInterval(6565);ServletContext ContextA = session.getServletContext();ContextA.setAttribute("session", session);//测试HttpSession session2 =(HttpSession)ContextA.getAttribute("session");System.out.println("IN SessionRangleServlet name : "+session2.getAttribute("username"));System.out.println("IN SessionRangleServlet name : "+session2.getAttribute("password"));}接受项目为D
public void onGetTextbox() throws InterruptedException{ SimpleSession s = (SimpleSession) Executions.getCurrent().getDesktop().getSession(); HttpSession session1 = (HttpSession) s.getNativeSession(); ServletContext Context = session1.getServletContext(); ServletContext ContextA= Context.getContext("/C"); HttpSession session2 =(HttpSession)ContextA.getAttribute("session"); String message = "base传过来的user为:"+session2.getAttribute("username")+"&&&"+session2.getAttribute("password");System.out.println(message);Messagebox.show(message);}tomcat配置crossContext="true"
<Context docBase="C" path="/C" reloadable="true" crossContext="true" source="org.eclipse.jst.jee.server:C"/> <Context docBase="D" path="/D" reloadable="true" crossContext="true" source="org.eclipse.jst.jee.server:D"/>
如果是普通的java项目session获得
HttpSession session1 =request.getSession();
- 一个tomcat下两个项目(ZK项目)共享session
- 同一个tomcat下两个项目实现session共享
- Tomcat中两个不同项目共享Session
- Tomcat中两个不同项目共享Session
- Tomcat中两个不同项目共享Session
- Tomcat中两个不同项目共享Session
- Tomcat中两个不同项目共享Session
- Tomcat中两个不同项目共享Session
- 同一tomcat下不同web项目session共享方法
- 在同一个tomcat下,不同的web项目共享session
- 在同一个tomcat下,不同的web项目共享session
- 在同一个tomcat下,不同的web项目共享session
- 在同一个tomcat下,不同的web项目共享session
- 在同一个tomcat下,不同的web项目共享session
- 在同一个tomcat下,不同的web项目共享session
- 在同一个tomcat下,不同的web项目共享session
- 同一tomcat下不同web项目session共享方法
- 在同一个tomcat下,不同的web项目共享session
- swap的真正作用
- 我想以后记着你心里都是你,再去爱别人。
- JMeter入门6---分布执行
- JSON对象与JSON字符串相互转换
- 理解Cocos2d里的anchorPoint
- 一个tomcat下两个项目(ZK项目)共享session
- 圆的计算
- android中的AdapterView阅读
- Linux内核启动流程分析
- VIM编辑和查看二进制文件
- dereferencing pointer to incomplete type 错误
- 你要离开我不会挽留,我会给你我仅有的,放你自由
- Xcode:用bash统计代码行数
- GDB基本命令