I have developed a simple web application using JSP. It has a login page which contains username, password fields and sumbit button. It has a logout page which contains a link to the login page. And there are some pages like page1, page2, page3, page4, etc.
Normal workflow is the following:
- After login comes page1.
- Then click some action and it will go to page2.
- Then click some action and it will go to page3.
- Then click some action and it will go to page4. So now I am in page4.
- Now click back button in navigation toolbar in browser, generally go to previous page (page3).
But my requirement is, if you click back button in navigation toolbar from any page in the application, then you should go to logout page. For example: if you are in page4 and press the back button, then you should go to logout page and not to page3.
How to achieve this? Is it anyway possible? Maybe with Javascript?