File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes j2ee application instance in tomcat container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "j2ee application instance in tomcat container" Watch "j2ee application instance in tomcat container" New topic
Author

j2ee application instance in tomcat container

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

hi guys,

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 for helping.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Sessions normally time out after some time. You can set the timeout period in the deployment descriptor (web.xml) like this:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

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 .

thanks much .
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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).
Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

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 ?

thanks much.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: j2ee application instance in tomcat container
 
Similar Threads
Is it possible to merge two session?
Long running request returns no HTTP response
Wierd issue with tomcat - ServiceClient invocation timing out after 15 seconds
Does a Connection time out?
Tomcat Issue