如何检查java中的会话已经过期? [英] how to check session has been expired in java?

查看:246
本文介绍了如何检查java中的会话已经过期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还有其他方法来检查除此之外的会话到期吗



session.isNew()

解决方案

定义一个类,比如 SessionTimeoutIndicator ,它实现了接口 javax.servlet.http.HttpSessionBindingListener



接下来创建一个 SessionTimeoutIndicator 对象并将其添加到用户会话中。



删除会话后,Servlet引擎将调用 SessionTimeoutIndicator.valueUnbound()方法。



然后,您可以实施 valueUnbound()来执行所需的操作。



<希望它现在已经清除。


Is there any other way to check expiry of session other than this

session.isNew()

解决方案

Define a class, say SessionTimeoutIndicator, which implements the interface javax.servlet.http.HttpSessionBindingListener.

Next create a SessionTimeoutIndicator object and add it to the user session.

When the session is removed, the SessionTimeoutIndicator.valueUnbound() method will be called by the Servlet engine.

You can then implement valueUnbound() to do the required operation.

Hope it's cleared now.

这篇关于如何检查java中的会话已经过期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆