• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Implementing timeout in JSP  RSS feed

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing soln for Timeout on inactvity. Two ways not clear:

1. Jsp makes brief connect and does some sql. Now, I am not sure if webserver(Tomcat) will senese first connect and keep it open till user
closes browser or up to certain magical seconds. So should use timeout set
in web.xml for session to implement this. I have read about session inacivity interval but not found working in JSP's. For our web server it is 30 minutes. But we are never conected for 30 minutes for doing sql ..

2. Sense client inactivity buy using various events. This is not simple to implement as there can bemany such events.

Will be intrested to know how someone has successfully implemented this.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1- Its not at all a good idea, doing SQL in JSP. Database access should be on a seperate layer.

2- If you really want to do that then, why not using JSTL SQL Tags.

3- Whether using JSTL SQL Tags or scriptlets, just open the connection for a particular transaction/read after that close the connection. Never ever dedicate a connection to a user.

4- You can also go for connection pooling mechanism. A better idea.
[ March 27, 2005: Message edited by: Adeel Ansari ]
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here the issue is to track the user inactivity time, right?

I feel the better way to use HttpSessionLisener. Why is not working from JSPs?

JSPs are ultimately servlets, so it should work.

Please be clear so that we could get a good grasp of the issue

Regards
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sarath Mohan:
I feel the better way to use HttpSessionLisener.



Do you mean bind the connection object to the user session?
 
Raj Puri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the issue is to implement timeout. I tried to implement on JSP layer
by setting inactivity time in web.xml(the dafault 30 minutes for tomcat) and checking if is new session or not. If is session that means I was timed out. My assumption was that once first sql call is made the connection is maintained by jsp so subsequent call will yield newsession false. This does not work consistently. I need to have a whole different direction.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!