1
votes

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.

1
Sorry if the code was not clear, I put a Sysout in the code to say if(FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("app1Bean") == null) { System.out.println("app1Bean is null");} and this Sysout shows up on the consoleuser972391
Are those applications configured on the server to use the same session? Sounds like not, but maybe it was not really obvious for you, just asking to be sure.BalusC
I am almost sure such settings are NOT being set (Websphere 7.0). Is that the only way to achieve what I want?user972391

1 Answers

0
votes

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.