Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session

 
Vallabhaneni Suresh Kumar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In servlets I want to do something,when the session expires.How to achive this?

Thank you
 
Adeel Ansari
Ranch Hand
Posts: 2874
 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To add to the previous (excellent) reply:
- You implement HttpSessionListener.
your implementation would have code to run when session expires.
- You register this class in your web.xml:
<listener>
<listener-class>yourPackage.YourListener</listener-class>
</listener>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic