File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes back button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "back button" Watch "back button" New topic

back button

pooja jain
Ranch Hand

Joined: Jan 12, 2005
Posts: 213
what is the good way to implement back button?

one is history.go(-2), it looks good at first go. but there is an issue here:

it just shows the back page from browser history. this is what it is supposed to do.

but consider this scenerion:

assume there is a form and submit button on above page. now what happens is, in case of any invalid form field, we set error attribute to request, and we forward request to same page, and since request attribute is set, we will get this error message.

now user correct the form and submit again. this time no error so user go to next page. now on this next page there is a back button. if user clicks on it user will see the previous page with error. this is definitely wrong.

any suggestion here?
[ November 07, 2008: Message edited by: pooja jain ]

Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
You could consider using to prevent caching of page:

Please see:

Thanks and Regards
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Satya Maheshwari:
You could consider using to prevent caching of page:

Please see:

yes.. it is good. also maintain the session according to your needs
I agree. Here's the link:
subject: back button
It's not a secret anymore!