
2008-7-2 03:39
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 08:09
justforregister
这东西似乎不太好用,好像性能也不好
2008-7-2 08:35
developerm
是不是和web平台有关呀
2008-7-2 09:06
iooyoo
syssession=new SysInformation();
做了些什么?
2008-7-2 22:22
bhan2008
[quote]原帖由 [i]dnpy[/i] 于 2008-7-2 03:39 发表 [url=http://www.itpub.net/redirect.php?goto=findpost&pid=10825366&ptid=1015068][img]http://www.itpub.net/images/common/back.gif[/img][/url]
在不重启IE时以不同帐号登入
却是同一个SESSION,重启IE后SEEION又更新.也就是不重启IE时无论以什么帐号登入都是第一个用户的SESSION.
[/quote]
同一个浏览器进程与服务器之间的会话,本来就是一个session,有什么不对的呢?准确地讲,[color=red]第一个用户的SESSION[/color]这种说法是不正确的,应该说是session中保存了第一个用户的信息。楼主session更新指的应该是session中保存的对象的更新,而不是session本身。所以在登陆时候,应该及时把session中的用户信息更新,而不是把这些工作交给监听器去做。
2008-7-3 11:28
dnpy
[quote]原帖由 [i]bhan2008[/i] 于 2008-7-2 22:22 发表 [url=http://www.itpub.net/redirect.php?goto=findpost&pid=10835620&ptid=1015068][img]http://www.itpub.net/images/common/back.gif[/img][/url]
同一个浏览器进程与服务器之间的会话,本来就是一个session,有什么不对的呢?准确地讲,第一个用户的SESSION这种说法是不正确的,应该说是session中保存了第一个用户的信息。楼主session更新指的应该是session中保存的对象的更新,而不是session本身。所以在登陆时候,应该及时把session中的用户信息更新,而不是把这些工作交给监听器去做。 [/quote]
'session更新指的应该是session中保存的对象的更新,而不是session本身。所以在登陆时候,应该及时把session中的用户信息更新'
这个session中保存的对象的更新应该从哪里取得?
页:
[1]

Powered by ITPUB论坛