• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How many sessions are there?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Pay attention! Tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic