• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Will Session timeout while the servlet is being executed?

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeroen is probably right. I hadnt, in my post, considered the possibility of the request timing out.

ram.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic