how to keep session active without increasing session timeout


Web tier: servlets, JSP, Web frameworks: how to keep session active without increasing session timeout

  1. I have a session timeout of 10 mins.However for uploading & processing a large upload , it takes longer.I don't want to increase session timeout & want a way around to keep sessio n active.
    for info i am using weblogic ,j2ee
  2. kind of a hack... but...

    when you got to upload, put in 2 frames... your "real" frame for the upload and a 1 pixel frame that just does a meta refresh to keep pinging the session. just have the form taget the top of the frameset when you are done, so the session will expire normally after the fact.

    that said...

    you might want to reconsider your use case so you don't have to sit there for 10min+ time while the app is processing the file. is the majority of time in the upload or the processing? if its the processing, perhaps you could send a response after the file is uploaded, and use a separate thread for processing.

    hope this helps.

  3. problem still there[ Go to top ]

    thanx tim,
    story is that the files are large ones - 50MB range.When uploaded there is a whole lot of processing done to validate before starting upload.I am using a thread on the server which keeps sending a space to the client every minute so that the pipe between client - server is intact.But when the uploading is complete & the server tries to send the acknowledgement , i think it finds a cookie which is inactive for more than session time , hence it shows session timeout. There should be some thing which should update cookie with the recent timestamp so that server assumes the client to be active.
  4. problem still there[ Go to top ]

    put simply, the session will timeout if the time between client requests exceeds the session timeout. so you need to make sure that the client periodically tells the server, "i'm still waiting" so that the session won't go away.

    i think your basic approach is ok, you'll just need to sort of reverse it... and have the separate thread work on the file processing, instead of rendering the response.

    every time the client sends a request, either (a) send back an immediate response ('PROCESSING...') or (b) if finally done, then send back the actual response page ('FINISHED').

    then use a meta refresh on the 'PROCESSING...' page to keep pinging the server every minute or so.

    should work like a champ.