• 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

Question on HttpSession

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can HttpSession object be shared across multiple web applications deployed same/different JVMs? Can the same session object be retrieved using getSession() method?
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes a container should be able to migrate a session object from VM-A to VM-B
the container should migrate all the stored objects as attributes as well.
However the HttpSession should live in only one VM at a time.
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes sessions are migrated across JVM, and you have the HttpSessionActivationListener to notify the attribute classes about the migration..and NO, the container WILL NOT migrate all the attributes, instead it will migrate only the serializable attributes and the non-serializable ones must be dealt with manually implementing the HttpSessionActivationListener interface.
there is a neat discussion on this in HFSJ
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jayashree Mohan:
Can HttpSession object be shared across multiple web applications deployed same/different JVMs? Can the same session object be retrieved using getSession() method?



I think HttpSession can not shared across multiple web application.

In the SVR 7.3 of Servlet Specification it is clearly specified.

HttpSession objects must be scoped at the application (or servlet context) level.The underlying mechanism, such as the cookie used to establish the session, can be the same for different contexts, but the object referenced, including the attributes in that object, must never be shared between contexts by the container.



In the distributed environment the session can be migrated to JVMs in which the application is running.


But practically it is possible to share the session in different application if you are using mechanism like SSL or Single Signon in the large scale Enterprose applications.


Hope this help you.

Thanks
 
Akshay Kiran
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
narendra
you are clearly confusing the words "sharing" and "migrating"
there is a vast difference.
sharing means being available to two different contexts concurrently
and migrating means changing hands, i.e getting transferred from the scope of one context to another.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Akshay Kiran:
narendra
you are clearly confusing the words "sharing" and "migrating"
there is a vast difference.
sharing means being available to two different contexts concurrently
and migrating means changing hands, i.e getting transferred from the scope of one context to another.



Hi,

There is no confusion in sharing and migrating.

According to the spec. You can not share and migrate the session in another web application as the Httpsession object is scoped to application only.

In the distributed environment, you can migrate session from one JVM to another JVM as the same application is running in different JVMs. But the session is active only in one JVM at the point of time. This is not sharing.

In the last part I am talking about the large scale enterprise application, where the out of box mechanism is used to maintain the sessions accross differnt applications, here you can share the same session information across the applications. I typically pointing to Single signon applications provided by the Oracle, Sun, IBM in enterprise environment. I do not know the exact mechanism used in this, but you can able to share the session information using this applicatins.

Thnaks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic