• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

j2ee application instance in tomcat container

 
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sessions normally time out after some time. You can set the timeout period in the deployment descriptor (web.xml) like this:
 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic