aspose file tools*
The moose likes Servlets and the fly likes Disabling session when clicking Back button and redirecting to Login page with message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Disabling session when clicking Back button and redirecting to Login page with message" Watch "Disabling session when clicking Back button and redirecting to Login page with message" New topic
Author

Disabling session when clicking Back button and redirecting to Login page with message

Yugandhar Ghanta
Greenhorn

Joined: Jan 12, 2009
Posts: 6
Hi friends,

How to disable session in web application whenever user click on back button of browser and also need to redirect him to some error page...
Thanks in advance,
Yugandhar...

Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You can not capture the fact that the back button on the client was clicked. You should t least disable caching on the client.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Yugandhar Ghanta
Greenhorn

Joined: Jan 12, 2009
Posts: 6
Hi Bosun Bello ,

Thanks for your reply, i thought same on this...But, in some sites(e.g. bank sites) i found clicking back button is redirecting to Some Error page. I need to implement same in my current project. Present, we are disabling back button functionality by using Java script. But, we need to implement it as disabling session and redirect user to error page(with some message and login page link).

Thanks...
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Yugandhar Ghanta wrote:
How to disable session in web application whenever user click on back button of browser


if you invalidate the session then you click browser back button . do you think the same session become active ?
Yugandhar Ghanta
Greenhorn

Joined: Jan 12, 2009
Posts: 6
Hi All,

Here, i need to invalidate session whenever user clicks on Back button in any page of web application...
(not like, clicking Back bnutton after invalidating session )

Please provide your thoughts ASAP...

Thanks,
Yugandhar.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Yugandhar Ghanta wrote:

Here, i need to invalidate session whenever user clicks on Back button in any page of web application...



i am not sure . but whenever user click the back button , we can track the behaviour (it is nott 100% )through below javascript code . inside the javascript function you need to call java method which wiill invalid user session

javascript code:
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You seem to insinuate that the onbeforeunload will be triggered only when the user pressed the back button.

You´re wrong.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Yugandhar Ghanta wrote:Hi friends,

How to disable session in web application whenever user click on back button of browser and also need to redirect him to some error page...
Thanks in advance,
Yugandhar...


You´re looking for a solution in the wrong direction.

Right solutions involve under each disabling the response caching, the POST-Redirect-GET pattern and/or a solid authentication filter.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks Bauke
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Disabling session when clicking Back button and redirecting to Login page with message