This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can i update the databse for partcular user_id after session is expire ?

 
shyam ji gautam
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear all


i want to update the data for particular userid in database after session is expire how i can do this ?

first i elaborate the actual requirement in my application i want then when session time out happen then one particular flag for user id like 'test' is set ='no' and send the page to login.jsp
using filter
i am using hybernate so how can i update that flag for particular userid after the session is expire using hybernate .

 
Tim Moores
Bartender
Posts: 2674
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use an HttpSessionListener to get notified whenever a session expires.
 
shyam ji gautam
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using hybernate so how it will be doing in hybernate and my doubt is that how i pass the particular id key for update the row.
 
Tim Moores
Bartender
Posts: 2674
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would get the ID out of the session (where, obviously, you'd need to store it first). The rest is just JDBC/Hibernate.
 
shyam ji gautam
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks

i am also confue can you give some code like we wnt to update data for user_id ='test' ;

then if session time out then how we use this id for update in databse in listener as your suggestion , any example
 
Tim Moores
Bartender
Posts: 2674
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What difference does it make whether you call this code from within a servlet context listener, or any other place? I think for DB questions there's a separate forum here which would be better suited.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is one example of session listener.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic