| Author |
servlet context vs session
|
Buk Lau
Greenhorn
Joined: Nov 06, 2002
Posts: 4
|
|
When would you use one over the other and why? Thanks in advance, Buk
|
 |
Chris Stehno
Ranch Hand
Joined: Feb 26, 2001
Posts: 180
|
|
The ServletContext is shared throughout an entire context. You would store data in it that is not modified by user actions (unless you want the changes to be global)... DataSources, read-only caches, etc. The Session object exists for each user coming through the context. It is useful for storing user state data such as a User object of some sort, or wizard-style temporary variables between pages, etc. Try to put more data in the ServletContext rather than the Session context. Since each visitor has its own session, session objects can really build up memory usage. Hope this helps.
|
- Chris Stehno, SCPJ
|
 |
 |
|
|
subject: servlet context vs session
|
|
|