0

How can I maintain a SessionScoped object between redirects? I have a main page which accesses a Stateless bean.

I also have a button which is doing a redirect (FacesContext.getCurrentInstance().getExternalContext().redirect("/to/my/sevlet");) to a specific path, and by this invoking the webservlet. The webservlet itself creates some contition-based response, but that should not matter at the moment.

The problem is: when I'm redirected to the servlet, I lose my session scoped bean property that was set during the initial access of the stateless bean..

How can I maintain a sessionscope between pages switch/redirect?

@Stateless
class myStateless {
    @Inject
    MySessionBean sessionBean;

    private doSomething() {
        sessionBean.setSessionProperty(true);
    }
}


@SessionScoped
class MySessionBean {

    Boolean sessionProperty = false;
}


@WebServlet
class MyWebServlet {
    doGet(..) {
        out.println("session property status is" + String.valueOf(sessionBean.isSessionProperty()); //always false
    }
}
4

1 回答 1

0

I found out that the setup is fine. I just made a reference call to a no-session scoped var.

于 2012-08-26T10:29:22.607 回答