ITPUB论坛 » Java企业开发 » 求助~~关于session的问题


2008-7-2 03:57 dnpy
求助~~关于session的问题

同一个应该程序包(sevlet+jsp) 在中间件是tomcat时启动时提示监听程序创建成功且session创建成功,退出系统时session销毁.都正常.

可是在websphere下提示监听程序创建成功且session创建成功,却退出系统时却没有了监听提示,并且随后出现SESSION混乱,在不重启IE时以不同帐号登入

却是同一个SESSION,重启IE后SEEION又更新.也就是不重启IE时无论以什么帐号登入都是第一个用户的SESSION.

求大哥,大姐,帮忙想想会是为什么?急呀!下面是监听代码:

package com.hss.sys.comm;

import java.io.File;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;

import com.icsshs.j2ee.db.DbConnection;
import com.icsshs.j2ee.db.SysInformation;

public class SessionListener extends com.icsshs.service.framework.context.ContextSessionListener{

ServletContext application=null;
String path=null;

public SessionListener() {
  super();
}

protected void performContextCreated(ServletContextEvent arg0) {
  System.out.println("RpS平台监听程序开始创建.....");
  
  application=arg0.getServletContext();
  DbConnection sysapplication=null;
  if (application.getAttribute("RpsSysapp")==null){
   sysapplication=new DbConnection();
   application.setAttribute("RpsSysapp",sysapplication);
  }else{
   sysapplication=(DbConnection)application.getAttribute("RpsSysapp");
  }
  try{
   path=arg0.getServletContext().getRealPath("/");
   javax.xml.parsers.DocumentBuilderFactory fac=javax.xml.parsers.DocumentBuilderFactory.newInstance();
   javax.xml.parsers.DocumentBuilder builder=fac.newDocumentBuilder();
   org.w3c.dom.Document doc=builder.parse(path+File.separator+"jndi"+File.separator+"jndi.xml");
   org.w3c.dom.NodeList list=doc.getElementsByTagName("data");
   String[][] strarray=new String[list.getLength()][3];
   for(int i=0;i<list.getLength();i++)
   {
    org.w3c.dom.NodeList dslist=((org.w3c.dom.Element)list.item(i)).getElementsByTagName("ds");
    for(int j=0;j<dslist.getLength();j++)
    {
     org.w3c.dom.Element link=(org.w3c.dom.Element)dslist.item(j);
     String name=link.getAttributes().getNamedItem("name").getNodeValue();
     String jndi=link.getAttributes().getNamedItem("jndi").getNodeValue();
     if (sysapplication.getKeyInfo(name)==null){
      sysapplication.setKeyInfo(name,jndi);
     }
     strarray[i][0]=name;
    }
    org.w3c.dom.NodeList proclist=((org.w3c.dom.Element)list.item(i)).getElementsByTagName("proc");
    for(int k=0;k<proclist.getLength();k++)
    {
     org.w3c.dom.Element link=(org.w3c.dom.Element)proclist.item(k);
     String name=link.getAttributes().getNamedItem("name").getNodeValue();
     String value=link.getAttributes().getNamedItem("value").getNodeValue();
     strarray[i][1]=name;
     strarray[i][2]=value;
    }
   }
   if (sysapplication.getKeyInfo("applicationcleanproc")==null){
    sysapplication.setKeyInfo("applicationcleanproc",strarray);
   }
   System.out.println("RpS平台监听程序创建成功!");
  }catch(Exception e){
   System.out.println("RpS平台监听程序创建失败:"+e.getMessage());
  }
}

protected void performContextDestroyed(ServletContextEvent arg0) {
  application=null;
}

protected void performSessionCreated(HttpSessionEvent arg0) {
  HttpSession session=arg0.getSession();
  SysInformation syssession=null;
  if (session.getAttribute("RpsSession")==null){
   syssession=new SysInformation();
   session.setAttribute("RpsSession",syssession);
  }else{
   syssession=(SysInformation)session.getAttribute("RpsSession");
  }
}

protected void performSessionDestroyed(HttpSessionEvent arg0) {
  // TODO 自动生成方法存根
  System.out.println("RpS系统SESSION销毁");
}
}

2008-7-2 22:24 justforregister
不要一贴多发

2008-7-3 11:00 aeoluskim
没见你哪个地方有清除session的代码啊.application作用域这么大,动不动就清除啊?

[[i] 本帖最后由 aeoluskim 于 2008-7-3 11:13 编辑 [/i]]

2008-7-3 11:29 dnpy
回复 #2 justforregister 的帖子

初次发帖,不知道在哪儿发好些.请见谅.

页: [1]
查看完整版本: 求助~~关于session的问题


Powered by ITPUB论坛