有没有办法从 EJB 模块访问 HttpSession?

发布于 2024-08-29 06:35:42 字数 97 浏览 1 评论 0原文

我目前需要获取会话 ID,因此我需要获取 HttpSession,但我的 EJB 模块中没有任何 servlet。那么也许像 webservices api 中的一些 DI 注释?

I'm currently in a need of getting session ID thus I need to get the HttpSession but I don't have any servlets in my EJB module. So perhaps some DI annotation like in webservices api?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

云仙小弟 2024-09-05 06:35:42

EJB 技术不依赖于 HTTP,因此绝对没有理由在 EJB API 中包含 HTTP 特定的内容。如果您需要来自 EJB 的会话 ID(想知道为什么),请将其作为参数从 Web 层传递(从技术上讲,您甚至可以将引用传递给 HttpRequestHttpSession 对象并从 bean 中读取它,但这将是一个可怕的、错误的、异端的设计,EJB 不应该遵守 Servlet API)。您也许应该澄清您的要求。

The EJB technology doesn't rely on HTTP so there is absolutely no reason to have HTTP specific stuff in the EJB API. If you need the session id from an EJB (wondering why), pass it as parameter from the web tier (technically, you could even pass the reference to the HttpRequest or the HttpSession objects and read it from the beans but that would be an horrible, wrong, heretic, etc design, EJBs shouldn't have adherences to the Servlet API). You should maybe clarify your requirement.

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