Question

I have a JSF 2.0 application(App#1) that has a managed Session Scoped bean that does some business logic like validation etc. After the Continue button is clicked, another plain html form page is shown to the User and clicking on Submit button on this page will submit the form to a different application (App#2). After App#2 does it's job, the User is shown a page from App#3. Please note that all of this happens in the SAME browser tab.

In the App#3 (which is also a JSF 2.0 application), I would like to remove the App#1 's session scoped bean. How do I do that? I tried the below options, but none of them seem to work.

//First approach
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("app1Bean");

I am getting null for the above line of code

//second approach
HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
        .getExternalContext().getSession(true);
session.removeAttribute("app1Bean");

Null here too.

Was it helpful?

Solution

By default, multiple applications which run on the same server do not share the same session. The server can however be configured to do so. How exactly to do that depends on the server make/version. Consult your server admin for details.

If changing the server configuration is not an option, then your best bet is to store the information which you stored in session in a shared datasource (a SQL database, for example) instead. This way the last application has just to remove or manipulate the information in the datasource and you don't need to fiddle with the session scope anymore.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top