将值从 Java 操作类传递到 ejb?

发布于 2024-10-04 21:45:49 字数 96 浏览 0 评论 0原文

我开发了一个网络应用程序。我将会话 ID 放入哈希表中。我想在ejb中使用这个哈希表。意味着我想在 ejb 中使用这个登录会话。

是否可以?我怎样才能做到这一点?

I have developed a web application. I put session id in hashtable. I want to use this hash table in ejb. Means I want to use this login session in ejb.

Is it possible? How can I do that?

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

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

发布评论

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

评论(2

九八野马 2024-10-11 21:45:49

这并非不可能,但你绝对不能这样做。从 HttpSession 获取您需要的所有内容并将其作为方法参数发送到 EJB。例如:

public void doGet(HttpServletRequest request, HttpServletResponse response) {
    String foo = (String) request.getSession().getAttribute("foo");
    ejbService.doSomething(foo);
}

因此 - 通过应用程序的链层将所需的值作为参数传递给方法。

It's not impossible, but you must not do it. Get everything you need from the HttpSession and send it to the EJB as method parameters. For example:

public void doGet(HttpServletRequest request, HttpServletResponse response) {
    String foo = (String) request.getSession().getAttribute("foo");
    ejbService.doSomething(foo);
}

So - pass the values you need as parameters to methods, through the chain layers of your application.

蓝颜夕 2024-10-11 21:45:49

安全凭证自动从 servlet 传递到 EJB。如果您的用户已通过 Web 容器的身份验证,那么您不需要自己做任何工作。

在会话 bean 中,按照描述获取 EjbContext 链接文本

 @Resource
 private SessionContext sctx;

,然后调用诸如

 sctx.getCallerPrincipal();  

Security credentials are passed automatically from servlet to EJB. If your user has authenticated to the Web Container then you don't need to do any work yourelf.

In the session bean get the EjbContext as described link text

 @Resource
 private SessionContext sctx;

and then call methods such as

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