jsp的session
我在一个JSP页面中用session保存了一些信息,我想当用户离开该页面的时候使该session无效。我该怎么做? 问题点数:50、回复次数:5Top
1 楼Mars_lee(二子)回复于 2002-02-20 17:39:15 得分 10
removeAttribute
public void removeAttribute(java.lang.String name)
Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.
After this method executes, and if the object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueUnbound.
Parameters:
name - the name of the object to remove from this session
Top
2 楼scarab(没有尾巴的鲨鱼)回复于 2002-02-20 17:42:49 得分 0
有没有方法判断我离开该页面了呢?(虽然我认为不可能,但是有没有好方法进行判断呢?)Top
3 楼Hikaru(光)回复于 2002-02-20 17:44:21 得分 10
session不是有类似invalidate()之类的函数么,设一下就行了~Top
4 楼Hikaru(光)回复于 2002-02-20 17:48:00 得分 15
什么叫离开页面,关闭IE?这样session肯定就没了。
你是说切换到其他页面?那么应该给个logout按钮之类的,你可以清掉session,不然认为用户还是在这次对话中是理所当然的~Top
5 楼yanchang(笨笨)回复于 2002-02-20 18:07:35 得分 15
HttpSessionBindingListener.valueUnbound(HttpSessionBindingEvent event)
可以吗?Top




