Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Will Session timeout while the servlet is being executed?

 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I invoke a servlet which inturn invokes a few DB2 sps to get the job done.
Each of the DB2 sps takes approximately 20 mins to complete ( There is some complex logic in each). In the midst of this processing is there any possibility of session expiring? I mean, assume that my session time out is 30 mins. And if my servlet takes 45 mins to execute, will my session time out in the middle of processing? If yes, then how do i prevent this from hapanning?

regards,
Saj
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No need to worry about the session expiring. The request will time out long before that might possibly happen.

This will never work.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the container that checks for session validity.

This means that once a request is accepted by the container to contain a valid session and the associated server side process invoked to service it, there isnt any danger of the session being invalidated at any point further on in that request cycle, irrespective of the length of the time taken by the process to service the request.


However the next request may not have a valid session. By the time the response is sent to the browser and the client makes the next request, the time elapsed between that request and the previous one would be greater than the max inactive interval.

This is because the Servlet/Jsp takes a longer time to process the first request than the max inactive interval of the session. The container unaware of this, just checks the time between 2 subsequent requests and finds that the difference is greater than the max inactive interval and invalidates the session.

The above maybe container specific and you have to test it out on the server you are working with. You should consider setting the max inactive interval to a value greater than the sum of the maximum time that the servlet may take to process the request and the maximum think time.

ie session timeout > max server side process time + max allowable think time

cheers,
ram.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeroen is probably right. I hadnt, in my post, considered the possibility of the request timing out.

ram.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most common pattern used for long runninng server processes is the polling webpage.

The user submits the request.
The servlet kicks off the long running process, asynchronously, and returns immediately.
The webpage has a meta refresh tag that causes it to refresh itself every n secconds.
Each time the polling page refreshes, it checks the status of the long running process. If it's done, the results of the process are returned, otherwise, the polling page is returned.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic