简体   繁体   English

在Jersey Servlet和JSF Backing Bean之间共享范围

[英]Share a scope between Jersey Servlet and JSF Backing Bean

I just want to ask if anybody has done something like this. 我只想问问是否有人做过这样的事情。 Basically, it's like paypal express checkout functionality: 基本上,这就像贝宝快速结帐功能:

1.) You select item for checkout in merchant store. 1.)在商户商店中选择要结帐的项目。

2.) You will be redirected to a login page, in my case I implemented it as a Jersey Rest Servlet. 2.)您将被重定向到登录页面,在本例中,我将其实现为Jersey Rest Servlet。 On post, store the data in a session EJB backing bean and invoke Response.seeOther() to redirect to the login page (JSF). 发布后,将数据存储在会话EJB后备bean中,并调用Response.seeOther()以重定向到登录页面(JSF)。

3.) If the login is successful the posted transaction data should be persisted. 3.)如果登录成功,则应保留已过帐的交易数据。

But it seems, while I can invoke the session backing bean, store the posted data in a variable inside that bean. 但是看来,虽然我可以调用会话支持bean,但是将发布的数据存储在该bean内部的变量中。 When I click login (login ok) and I re-access the same bean, the variable where I store the posted data becomes null. 当我单击登录(登录确定)并重新访问相同的bean时,用于存储发布数据的变量将为null。

So is session scope not shared between Jersey Rest Servlet and Session scope backing bean in ejb? 那么,在ejb中的Jersey Rest Servlet和Session作用域支持Bean之间不共享会话作用域吗?

Any other good approach? 还有其他好的方法吗?

Thanks, 谢谢,
czetsuya 捷屋

Session scope is not available for web service calls. 会话范围不适用于Web服务调用。 You'd need to use Application scope, or create your own. 您需要使用应用程序范围,或创建自己的应用程序范围。

After trying to solve this problem, I've come to a conclusion that it's not possible to share jsf session to jersey or servlet session because they are implemented in a different way. 在尝试解决此问题之后,我得出的结论是,不可能将jsf会话共享到jersey或servlet会话,因为它们是以不同的方式实现的。

My solution to my problem (not answer to the question) is to use HttpServlet, and store the transaction as a session attribute: 我对问题的解决方案(不是对问题的回答)是使用HttpServlet,并将事务存储为会话属性:

HttpSession session = request.getSession(true);
session.setAttribute("POSTED_ITEMS", postedItems);

So I'll be able to access it to the next page. 这样我就可以访问下一页。

*I wish there's a way to post to a jsf page backed by javaee6 bean, that'll make life simple :-). *我希望有一种方法可以发布到由javaee6 bean支持的jsf页面,这将使生活变得简单:-)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM