• Post Reply Bookmark Topic Watch Topic
  • New Topic

Behavior of ServletContext VS Behavior of HttpSession

 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please tell me the difference between the "Behavior of ServletContext" VS "Behavior of HttpSession" in Distributed Environment?
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a distributed environment,
Each JVM will have a separate ServletContext. So you cannot depend on the Conetext level attributes while sharing attribute information

But the Session object is shared between all the JVM's present in the environment. You can test this out by implementing the HttpSessionActivationListener on your attributes.

The attributes will be passivated and then activated when they move from one server to another but in this case your attributes must be serializable.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!