• 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

Session v Servlet Context

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello !!!
Since servlet is something new for me!!! I am finding some difficulties to deal with it....

How are the sessions more advantageous than servlet contexts? I wanted an illiustration as well...So,i would be really thankful if any of u guys help me out of this!!!

[Edit by Dave to give a meangful subject]
[ April 25, 2006: Message edited by: David O'Meara ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use a meaningful topic, please use real words.

A session is related to a user, so each time the user provides a request you can look at the information attached to this user. A Servlet context is attached to a Servlet, and the same servlet serves multiple users. Therefore the two are not the same.

Dave
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gagan Sabharwal:
How are the sessions more advantageous than servlet contexts?



Sessions belongs to a particular user whereas servletContext is shared by all active users. We store all user related info to the session of that particular user like, role etc. Whereas servletContext is used to store appication level information.

Session remains valid only as long as the users browser stays open and user remains active.

Edited after Bear's post
servletContext remains valid until application goes out of service.
[ April 26, 2006: Message edited by: Adeel Ansari ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to make sure that there are no misconceptions...

servletContext should have been more properly named applicationContext. There is only one servletContext for the entire web app. It is not tied to any one particluar servlet. It comes into scope when the application is started, and stays in scope until the application is stopped. The servlets themselves can come into and out of scope and the servletContext is not affected.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic