I have using jsp technology in my project.I want to do session tracking
in my login form.
After logout when i press back button it should be show
session is expired.Please help me.
I have using jsp technology in my project.I want to do session tracking in
Share
You don’t need to do it manually. The servletcontainer will do it for you. You can access the tracked session by
HttpServletRequest#getSession(). All you need to do is to put the logged-in user as a session attribute.Let the rest of your code intercept on that. You usually use a
Filterfor this.When you invoke the logout, just remove the user from the session.
The servletcontainer will manage the session expiration as well. When it expires, then the
HttpSessionwill simply be trashed, including all of its attribtues.As to the back button question, just instruct the client to not cache the response so that it’s forced to fire a brand new request which would then be passed through the
Filter. This client instruction needs to happen by setting the response headers accordingly. That could be done in aFilteras well.