Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Back button and JSP  RSS feed

 
Alaa Abutabaq
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Do u have any idea how to deal with Back Button in IE 5.5 and up. to direct it to a specific url other that the actual previous url ?
Thanx
Ala'a
 
James Hobson
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

James
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
alaa
JavaRanch has a Naming Policy Following it is a requirement for entry to the Book Giveaway. Please change your Display Name to comply.
[ August 27, 2002: Message edited by: Carl Trusiak ]
 
Alaa Abutabaq
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks friends for your advices .
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!