"Lageson, Tom" wrote:
>
> I have been setting the servlet response with:
> > response.setHeader("Pragma", "No-cache");
> > response.setHeader("Cache-Control", "no-cache");
> > response.setDateHeader("Expires", 0);
> >
> This works as I want except for one thing. When the user hits the back
> button on the browser, there will be 1 - N pages saying that the "page has
> expired and to view this web page, click the Refresh button" with N being
> the number of times they went through this page. I do want the page to be
> expired.
>
> Is there a way to prevent this from happening? It is annoying to not be
> able to simply go back to the last page that hasn't expired.
I assume your invoking your servlet with the POST method. If so there's no
way to avoid it that I'm aware of. Since the page is expired the browser
must get it again from the server, but the HTTP spec says that POST may
have side effects (updating server-side contents, purchasing a product, etc)
so the browser must ask the user if he/she really want to make this request
again.
If you can use GET instead of POST you can fool the browser to do what you
want, but beware of server-side side effects. If you charge a credit card
when your servlet is invoked through GET, make sure you don't do it more than
once just because the user decided to us the Back button ;-) It can be tricky
but with some session data you can keep track of what the user has already
done and avoid surprises like this.
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html