tags:

views:

33

answers:

1

Hi, I am polling to a servlet which results in "No Session Time Out". Is there any way to time out session while polling?

A: 

You could put the sessionId (key) and timestamp (value) in a static HashMap on creation (indicated by session.isNew()).

And check during polling in your servlet whether you want to time out the session, which could be performed by invoking session.invalidate() http://download-llnw.oracle.com/javaee/1.2.1/api/javax/servlet/http/HttpSession.html#invalidate%28%29

stacker
but what if i was using application and continous polling doing?
Zeeshan
@Zeeshan I'm not sure what you mean. You should describe which behaviour you expect.
stacker
@Zeeshan If the client polls a again a new session will be created. So the client should stop polling. After invalidating the session on server side you could send an error response instead of OK to signal this to the client.
stacker