This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes how can i update the databse for partcular user_id after session is expire ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how can i update the databse for partcular user_id after session is expire ?" Watch "how can i update the databse for partcular user_id after session is expire ?" New topic
Author

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

shyam ji gautam
Ranch Hand

Joined: Sep 17, 2011
Posts: 48
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
You can use an HttpSessionListener to get notified whenever a session expires.
shyam ji gautam
Ranch Hand

Joined: Sep 17, 2011
Posts: 48
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Sep 17, 2011
Posts: 48
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Jun 06, 2007
Posts: 2716
    
    6

Here is one example of session listener.


SCJP, SCWCD.
|Asking Good Questions|
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how can i update the databse for partcular user_id after session is expire ?