J2EE——在提供 Flash 内容时处理 HttpSession 会话超时
在提供基于 Flash 的培训材料时,用户会定期遇到 HttpSession 会话超时。目前,不活动超时设置为默认值(30 分钟)。
问题:
对于请求培训 Flash 视频以防止超时的任何用户,尝试增加 MaxInactiveInterval 是个好主意吗?
如果 HttpSession 与查看培训内容相关联,更好的方法是使用 servlet 生命周期侦听器来重新激活 HttpSession 吗? -- 这可以更精确地控制 HttpSession 对象何时超时。
只有一小部分用户实际上会在任何时候查看此材料,这样做是否应该考虑性能损失?
While serving flash based training material users peroidically experience a HttpSession session timeout. Currently the inactivity timeout is set to default (30mins).
Questions:
Would it be a good idea to attempt to increase MaxInactiveInterval for any user who is requesting a training flash video to prevent the timeouts?
Would a better approach be to use a servlet lifecycle listener to re-activate the HttpSession if the HttpSession is associated with viewing training content? -- this may allow for more precise control over when the HttpSession object is going to timeout.
Only a small percentage of user's will actually be viewing this material at any one time, is there a performance penalty that should be considered for doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
而是在后台启动 ajax 民意调查。
这是一个 SSCCE ,有一点
这里
${pageContext.session.maxInactiveInterval}</code>
返回会话尚未生存的剩余秒数(并且稍微缩短了 - 只是为了与轮询保持一致 - 并转换为毫秒,以便它适合
setInterval()
的期望)。$.get('poll')
应该调用一个映射到/poll
的url-pattern
的 servlet,并且基本上包含以下内容doGet()
方法中的行。就是这样。
Rather fire ajax polls in the background.
Here's an SSCCE with a little help of jQuery. Just copy'n'paste'n'run it (and change the flash object to suit your actual code).
Here
${pageContext.session.maxInactiveInterval}
returns the remnant of seconds the session has yet to live (and is been a tad shortened -just to be in time with poll- and converted to milliseconds so that it suits whatsetInterval()
expects). The$.get('poll')
should call a servlet which is mapped on anurl-pattern
of/poll
and contains basically the following line in thedoGet()
method.That's it.
Flash 视频是否嵌入到 HTML 页面中?如果是这样,也许您可以在页面上进行 AJAX 调用,定期向服务器发送“心跳”以保持会话处于活动状态。
Is the flash video embedded in an HTML page? If so, perhaps you could have an AJAX call on the page that periodically sends a "heartbeat" to the server to keep the session alive.