You cant reliably do this -- the browser may simply get the page from Cache, and so you have no control. Probably your best bet, is to pass a transaction id (page view id or something) on the URL or as a hidden field, then check the client and server numbers when the client hits a link. If the numbers are not the same then you can do your custom "you pressed the back button" page.
Well, it is not exactly how to redirect user to a specific url, it is about back button in general. One way to solve back button problem is to keep all data that your page need on a page itself. Note , this is just something that I tryed and it worked, and had acceptable perfomance with about 77K of session info with page accessed through LAN . It will slow down page loading, but it not that bad, and anyway you not suppose to put a lot of data in a session. Also you could have some data on a session, but all your page specific info on a page - just find the right balance. .
So , instead of puttting data in session, I put it into my object. This object has HashMap inside, and for my convenience implements HttpSession interface (so it was easier to move my code to use this object). I transform this hashMap to String and put on web page as a hidden textarea field. I sent to a server with each form submission, and instintiate an object. When I transform it to string, I use ObjectOutputStream, ZipOutputStream and ByteArrayOutputStream, to minimize amount of information. this is object, that I used. Note, that bytesToString() and stringToBytes() was the fast solution guaranteed to work , not the best one. So saveIt method puts data into request, and constructor reads it from request.
and this is an example of useing it
[ August 28, 2002: Message edited by: Yuriy Fuksenko ]
Something must be done about this. Let's start by reading this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop