Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session

 
Ramakrishnan thiyagarajan
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic