File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Session cleared after first access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Session cleared after first access" Watch "Session cleared after first access" New topic

Session cleared after first access

Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
I am using JSF 2.0 with JBoss AS 7. I am attempting to use a session to store some user related information, but the session is somehow being cleared after the first access of the session.

When accessing the session, I use the following contained in the Post Construct of a Session Scoped bean:

When a fresh user navigates to the site the session is null as expected. As a result they are prompted to enter in some information which creates a new session, also contained in a Session Scoped bean, as follows:

The user is then redirected to the outcome page and the session map is accessed as above, this time the session is not null as expected and contains the data as entered. When the user navigates to any other page the session again is null when attempting to access it, even though the JSESSIONID is the same in both cases.

Thanks for any advice on this issue.
Ranganathan Kaliyur Mannar

Joined: Oct 16, 2003
Posts: 1101

I think you will get better responses from our JSF forum. Am moving this post there.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

It's better to simply inject objects when using JSF instead of doing explicit object location in code.

Nevertheless, you did a session.invalidate() right before you attempted to get the session.

An IDE is no substitute for an Intelligent Developer.
Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
Tim, thank you for your response. You were right I did call the invalidate method, although not the one that I had posted. Anyway you lead me down the path to finding the issue.
I agree. Here's the link:
subject: Session cleared after first access
It's not a secret anymore!