通过作为隐藏输入字段提交的会话 ID 获取 HttpSession

发布于 2024-12-28 04:35:35 字数 164 浏览 1 评论 0原文

是否可以通过会话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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断念 2025-01-04 04:35:35

如果您在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文