有没有办法从EJB模块访问HttpSession? [英] Is there a way to access HttpSession from EJB module?

查看:187
本文介绍了有没有办法从EJB模块访问HttpSession?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

EJB技术不依赖于HTTP,所以绝对没有理由在EJB API中具有HTTP特定的东西。如果您需要EJB中的会话ID(想知道为什么),请将其作为参数从Web层传递(从技术上讲,您甚至可以将引用引用到 HttpRequest HttpSession 对象和从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.

这篇关于有没有办法从EJB模块访问HttpSession?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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