如何检查sessionId在servlet中是否有效(java) [英] how to check if a sessionId is valid in a servlet (java)

查看:270
本文介绍了如何检查sessionId在servlet中是否有效(java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网络应用程序中维护了一个sessionid(s)和HttpSession对象的映射。我使用HttpSessionListener来填充或从地图中删除会话。当我的Web服务器崩溃并关闭并重新启动时,我需要一种方法来检查提交的sessionid是否有效。显然,当应用程序重新联机时,Map是空的,因此所有会话ID都是无效的,但我只是想要一些方法来检查传入的sessionid,如果可能的话......

I am maintaining a map of sessionid(s) and HttpSession Objects in my web app. I use an HttpSessionListener to populate or remove a session from the map. When my web server crashes and goes down and comes back up, i need a way to check if the sessionid being submitted is valid or not. Obviously, when the app comes back online, the Map is empty, therefore all session id's are invalid, but I just want some way to check the incoming sessionid, if possible, at all..

谢谢

推荐答案

您可以将这些保存在DB中的某些表中。这样它就不会受到撞击的影响。顺便说一句,服务器将会话序列化到磁盘,如果你也想要它们。

You can keep those in DB in some table. This way it will not suffer by the crash. And by the way, servers serializes the session to the disk, if you want them too.

这篇关于如何检查sessionId在servlet中是否有效(java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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