aspose file tools*
The moose likes Servlets and the fly likes Session management Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

Session management

Pratap gogireddy
Greenhorn

Joined: Dec 03, 2011
Posts: 7

hi friends

how the web server maintains the session with the client?

where the sessions are created and stored in servlets?


can any one please help me?

thanks in advance...
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

See my reply to your "Cookies" question - they are related.


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3855

how the web server maintains the session with the client?

Cookie is sent as a response header (or in the URL for browsers don't accept cookies) which in turn sent by the browser so that the container can match existing session with the given session ID.
where the sessions are created and stored in servlets?

Sessions are stored in the server memory. Servlets do not contain them but can access them through the HttpRequest object.

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

Vijitha Kumara wrote:Cookie is sent as a response header (or in the URL for browsers don't accept cookies)

Just to clarify - HTTP Cookies ONLY exist in the request & response headers, and not in the URL. HttpSession will use Cookies if it can, but will failover to using a sessionid in the URL if Cookies are disabled. In this case, you're technically not using HTTP Cookies (the browser does not allow them), but does show yet another advantage to using the higher-level HttpSession over the lower-level HTTP Cookie.
Pratap gogireddy
Greenhorn

Joined: Dec 03, 2011
Posts: 7
Thanks vijith and pete for your reply....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Session management