This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How many sessions are there?  RSS feed

 
Ron Alby
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First: I apologize for how little I know on this subject. I am a non-web Java guy who has been brought in on an emergency where I work. I fully acknowledge that I am out of my element.


The code in question stores and retrieves values in the session object. However, it appears to me that we are actually dealing with multiple session objects (at least that is one possible explanation).

We are dealing with JSF, JSP, and plain old servlets; a JSP page invokes the plain old servlet:


The plain old servlet and the backing bean are trying to exchange values via the session object ... however the results are very strange. We do not appear to be getting back the same data we put in. In fact, in some instances it appears we are getting back data that was entered several hours previously in a completely different run.

On top of all this, we are running in a clustered environment so different things may well be executing on different boxes. We didn't uncover this behavior until they promoted to the cluster.

The JSF accesses the session like this:


The servlet accesses the session like this:


Any suggestions would be greatly appreciated.

RonA
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One session will be created for each instance of a client application of each client computer (real or virtual). So all of the windows/tabs in a Firefox browser share the same session, but it's not the same session as IE running on the same machine, which will have its own session for its windows and tabs.

Most likely you need to ensure that the cluster's session-sharing configuration is correctly defined. Although anytime multiple JVM's are sharing information, life gets more complicated. Static variables no longer work properly, and there are even more opportunities for synchronicity issues than there are with a single server instance.

Your JSF code is OK, although the "reach-out-and-find-someone" (Service Locator) pattern isn't the ideal for JSF code. JSF is designed for Inversion of Control, so the preferred method of getting a Session-scope object into a JSF backing bean is to inject it as a Managed Property.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!