首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

tomcat上从应用2获取应用1session

2012-11-14 
tomcat下从应用2获取应用1session前提两个应用直接资源共享(见上一篇)?应用1: session.setAttribute(hell

tomcat下从应用2获取应用1session

前提两个应用直接资源共享(见上一篇)

?

应用1:

 session.setAttribute("hello","world");  this.getServletConfig().getServletContext().setAttribute("online",session);

?

应用2:

  ServletContext onlineContex=this.getServletConfig().getServletContext().getContext("/online");  if(onlineContex==null){   out.print("onlineContex=null");   return;  }else{  HttpSession onlineSession=(HttpSession)onlineContex.getAttribute("online"); if(onlineSession.getAttribute("hello")!=null){    out.print(onlineSession.getAttribute("hello"));     }}

?

热点排行