I found a trick to disable the back button somewhere some time ago. But it was a very bad trick but still I would like to mention it. In that you open the new page in a new window or tab and then close the current tab or window using javascript. I know this is very weird but well it is a solution
You can consider, disabling the caching of a page in the browser. For doing so, see this: https://coderanch.com/t/414250/JSP/java/back-button#1826301 Once this is done, any back button would result in the page being fetched from the server, and in the server you can handle your requirement, like invalidating the session(if it exists) and creating a new one.
Thanks and Regards
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
a bit of art, as a gift, that will fit in a stocking