• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on HttpSession

 
Jayashree Mohan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • 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?
 
Ernesto Leyva
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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.
 
Akshay Kiran
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • 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
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic