I am trying to understand the real purpose of session configuration in Web.xml for session timeout.
<!-- Session Configuration --> <session-config> <session-timeout>60</session-timeout> </session-config>
Now let me tell you about my question.
My application is importing/uploading a .txt file, which is bound to take more than 1 hour, since there are millions of records to be imported. But the session times out after 1 hour though my application is still importing that .txt file which is in progress. Such an application should not timeout as the application is doing some task in the background.
The session-timeout element defines the default session timeout interval for all sessions created in this web application. The specified timeout must be expressed in a whole number of minutes.
Session timeout represents the event occuring when a user does not perform any action on a web site during an interval (defined by a web server). The event, on the server side, changes the status of the user session to 'invalid' (ie.
To set a session-timeout that never expires is not desirable because you would be reliable on the user to push the logout-button every time he's finished to prevent your server of too much load (depending on the amount of users and the hardware). Additionaly there are some security issues you might run into you would rather avoid.
The reason why the session gets invalidated while the server is still working on a task is because there is no communication between client-side (users browser) and server-side through e.g. a http-request. Therefore the server can't know about the users state, thinks he's idling and invalidates the session after the time set in your web.xml
.
To get around this you have several possibilities:
<session-timeout>
inside the server but I wouldn't recommend thisThere was a similar question asked, maybe you can adapt parts of this solution in your project. Have a look at this.
Hope this helps, have Fun!
<session-config> <session-timeout>-1</session-timeout> </session-config>
You can use "-1" where the session never expires. Since you do not know how much time it will take for the thread to complete.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With