Search code examples
jsfjerseyjava-ee-6cdi

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.

2.) You will be redirected to a login page, in my case I implemented it as a 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).

3.) If the login is successful the posted transaction data should be persisted.

But it seems, while I can invoke the session backing bean, store the posted data in a variable inside that bean. When I click login (login ok) and I re-access the same bean, the variable where I store the posted data becomes null.

So is session scope not shared between Jersey Rest Servlet and Session scope backing bean in ejb?

Any other good approach?

Thanks,
czetsuya


Solution

  • 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.

    My solution to my problem (not answer to the question) is to use HttpServlet, and store the transaction as a session attribute:

    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 :-).