• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session Variables and DB access...  RSS feed

 
George Larry
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm developing a web page with a log in screen, but when the user logs in, they're actually logging into an Oracle db. I save their username and password as session variables and create the db connection in a header file I call from each page.
My question is- does this leave Oracle sessions open? If so- How can I close them...
How can I control the session? I want the users to be able to be idle for about 15-20 min without having to log back in. Can I set the time limit on a session variable? How can I have procedures run on expiration of those variables (to close the db and/or forward-or reverse them back to the login page)?
Thanks,
-George Larry
 
Ronald Francis
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand u correctly, the username and password are String objects , so keeping them in the session is harmless.
As for DB Connections , i would recommend using a Connection pool of some sort , and the best way to ensure that connections are closed ( or returned to a pool) is to do so maually after serving out a request.
As for controoling the session , you can set the timeout in web.xml .
To find out if a user's session had timed out , you may implement the HttpSessionListener interface.
Hope this helps ..
Good Luck..
 
Roger Graff
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can programatically set the session timeout by calling:
.
You can also specify the timeout in the web.xml file:

You should also have the objects you intend to store in the session implement the HttpSessionBindingListener interface. You then provide implementation for the methods valueBound(...) and valueUnbound(...) which are called when your objects are placed in the session and removed from the session respectively. Keep in mind that these methods are called when objects are removed from the session programatically as well as when the session times out.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!