通过作为隐藏输入字段提交的会话 ID 获取 HttpSession
是否可以通过会话ID获取HttpSession
对象,并将其作为隐藏输入字段提交给servlet?我无法通过 cookie 进行会话管理,因为设备不支持 cookie,也无法通过 URL 重写进行会话管理,因为会话 ID 不应显示在 URL 中。简而言之,如何使用隐藏输入字段进行会话管理?
Is it possible to get a HttpSession
object by session ID, which is submitted to servlet as a hidden input field? I cannot go for session management by cookie because the device will not support cookies, or by URL rewriting because the session ID shouldn't be displayed in URL. In short, how can I do session management using hidden input fields?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在 GET 表单中使用隐藏字段作为会话 ID,或在链接中使用查询参数,则会话 ID 将在 URL 中可见。
要执行您想要的操作,您必须专门使用 POST 表单或 AJAX。什么样的设备不支持cookie但支持JavaScript?
如果你仍然想走这条路,恐怕你必须自己重新实现会话处理,或者修改你的Web容器的会话处理代码。
If you use a hidden field for your session ID in a GET form, or query parameters in a link, the session ID will be visible in the URL.
To do what you want, you'll have to exclusively use POST forms, or AJAX. What kind of device would no support cookies but support JavaScript?
If you still want to go this way, I'm afraid you'll have to reimplement session handling yourself, or modify the session handling code of your web container.