Two Laptop Bag*
The moose likes Servlets and the fly likes session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session" Watch "session" New topic
Author

session

Ramakrishnan thiyagarajan
Ranch Hand

Joined: Oct 07, 2003
Posts: 57
hi,
multiple users are logging in different nodes,if one user disconect with he server then how would server identify the client session.I think
server is able to maintain each client sessionID.but if the sessionID expires then how would server know its state? i don't by means of cookies.
pls clarify my doubt.

regading
Ramakrishnan.T
,
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Ramakrishnan Thiyagarajan,

Speaking purely for myself, I think you're going to need to expand on your problem description a little as I can't quite grasp what you're getting at.

Taking a wild stab in the dark, are you familiar with getAttribute() and setAttribute() on HTTPSession?

Jules
Rovas Kram
Ranch Hand

Joined: Aug 08, 2003
Posts: 135
If you're asking: how would the server know if the user disconnected, then the answer is the server would not know. The server would continue to maintain the session for that user who disconnected until a predetermined amount of time of inactivity has passed - then the server would invalidate the session.
Ramakrishnan thiyagarajan
Ranch Hand

Joined: Oct 07, 2003
Posts: 57
Hi julian,
Thanks for ur resp.But my question is, "how would the webserver maintain the client state?"
The answer is the server maintain client state using HtppSession object.
getSession() method used to store information about particulat client.ok.

Actually server is able to maintain mutiple client's state information.if one user disconnect with the server then "how would the server know?."

I think server would not care of this which maintains client information even client disconnect with server.pls clarify my doubt
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
The server has no way of knowing whether a client has disconnected.
The server also has no way of assigning an existing session to another client.

[Edited to remove unnecessary comment]
[ August 18, 2004: Message edited by: Gregg Bolinger ]

42
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The server uses cookies, URL rewriting or SSL sessions to keep track of browsers sessions. Because HTTP is stateless, there is no way for the server to know when a client has disconnected; servers use a timeout to expire a session some time after the last request.

- Peter
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Paraphrasing what Jeroen and Peter have said, the misconception here is that the client is connected to the server. It's not (HTTP is stateless; disconnected). It may have an active session, but there's no connection as such, like with sockets. So the server can't know if the client "disconnects" as it was never connected in the first place.

Typically, a session will expire if no requests are made during a predetermined timeout period.

Does that make sense?

Jules
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: session
 
Similar Threads
Validation interceptor
Creating File object problem
FrontController to swing client
Passing files
chat program