> 1. Use POST but then do a redirect.
>
> You post to a page that updates the state (say add something
> to the basket)
> and then redirect to a page which display the new state
> (contents of the
> basket). This way the user can hit reload and it doesn't
> reapply the post.
> This still doesn't solve the back problem, but is useful in
> some situations.
Perhaps the one JSP page could be a little smarter and include some code to
deal with certain changes in state. Then it always returns itself. No more
need to redirect.
A redirect is possible, but it's extremely messy and unwise. Let me explain
why. Say you want to go from a JSP page to a servlet page and finish up on
another JSP page. And you want the page in the middle to not be included in
the user's history list. There are 2 ways to do this: bad and worse.
First the bad way. Remember Microsoft's stupid RegWiz? Every once in a
while Microsoft forgets who you are and probes you all over again, dragging
you through an afternoon full of questionnaires to eventually get to the
page you want. They did this by passing parameters with GET and they made
all pages in between expire immediately. If anything went wrong, you had to
start over. After the third try, you gave up and gave your stock broker
advance notice that you intend to invest in Red Hat when they IPO. All the
while, you're staring at a 10-mile long URL.
Now for the worse way. You can use client-side JavaScript to navigate
through your chain of URLs. Some pages (like the last one) you put into the
history buffer and some you don't (all the ones before the last one). Well,
there are 2 ways to move to another page.
1. window.location.href=url
or window.navigate(url)
2. window.open(url, false)
and window.open(url, true)
The preferred method (1) does not let you bypass the history.
The second method is evil. How many porn sites have you been to
accidentally that pop up 23 other windows when you try to leave? You don't
want to look like one of them. What we need is a window.navigate(url,
false) method.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".