前提两个应用直接资源共享(见上一篇)
应用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"));
}
}