Reputation: 6111
I face a scenario where everything works fine with keeping session.setMaxInactiveInterval(15*60) //15 minutes
Now, there is one request in application where number of users are getting saved, which takes more then 15 minutes at server side as internally many operations are involved while saving each user.
When saveUser operation is performed from browser, request received at server, starts processing, after 15 minutes client see "Session Time out" but user saving operation still going on.
I want to avoid this scenario, and need is when request is received by server at that time till the time it responds back to client don't considered in-between time as inactive time.
I can very well do it by making setMaxInactiveInterval(-1)
as first line of my method saveUser and just before giving response as setMaxInactiveInterval(15*60)
.
I am looking for standard approach or this is the standard approach to follow? Is there any inbuilt Tomcat configuration provided for such scenario?
Upvotes: 0
Views: 728
Reputation: 35008
The standard Java EE approach for this would be as follows:
N.B. blocking a thread in a server for 15 minutes is a very bad idea, because essentially it means that your servlet container wouldn't be able to do anything else with that thread. Imagine if a large number of those requests came in at the same time, your web layer would probably buckle under the pressure...
N.B.2: 15*50 does not make 15 minutes
Upvotes: 1