File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "session" Watch "session" New topic


Ramakrishnan thiyagarajan
Ranch Hand

Joined: Oct 07, 2003
Posts: 57
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.

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?

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 ]

Peter den Haan
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?

I agree. Here's the link:
subject: session
It's not a secret anymore!