we are running a servlet/jsp web application on tomcat container.
Basically when a user logs out from our application and even the web browser he used is closed the application instance still stays resident under Tomcat. It takes a long time for the app to close after the user has logged out and closed the browser. Assume two instances of the app are running under Tomcat (two users), One user logs out and closes the browser. For a long time after (20-60 min) Tomcat shows two instances still running.
what could be the cause of this issue ? & how to fix it?
thanks , I'll try this session timeout feature in web.xml
however ,i wanted to know if this session timeout setting will only take effect after the user browser is closed ? or will the user session expires after each 10 mins ? then user will need to log in again after session expires ? if this second case ,it will be an annoying limitation for our application.as we want user to keep his session information until he logs out or close browser. we would like to try other solutions if any .
No, this does not happen only after the browser is closed. HTTP is a stateless and connectionless protocol. The server cannot not know in any way if the browser on the client's computer is still open or not.
If you set the session timeout to 10 minutes, the session on the server will be removed automatically if the client does not send an HTTP request within 10 minutes (which means the user would have to log in again).
thanks for prompt reply. i was thinking to write a servlet listener class that will instruct tomcat session to timeout when web application is exited. i need to know what is the java code piece to instruct tomcat session to timeout from a servlet listener class ?
You can call invalidate() on the HttpSession object to end the session. This is what you should do when handling the logout action.
I'm not sure what you're trying to achieve by adding a servlet listener class to your application. I don't see what problem you're going to solve by doing this. How will the servlet listener class detect that the web application is exited? Because of the way the HTTP protocol works (connectionless) it is impossible to detect whether a user has closed the browser without properly logging out of the web application.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: j2ee application instance in tomcat container