"Wang, Dapeng" wrote:
>
> Hi,
>
> sorry for the belated response. I'm facing the same problem in the
> development. I am aware that a HTTP redirect requires one extra round trip
> to client, but RequestDispatcher.forward or jsp:forward may bring problems
> with browser reload. If a user fills in a form and pushes submit, one record
> (e.g an order item) will be inserted in the database by a servlet or a jsp,
> and the request is forwarded to another JSP(e.g. to show the order). At that
> moment if the browser reload button is pressed, the formeer servlet or JSP
> will be invoked again, which tries to insert the same record again in the
> database. So I think HTTP redirect should be used to prevent such duplicate
> data problem. Any comment?
Yes, I agree. In situations like this I usually redirect to a page showing
the result. You could, of course, use forward and guard against duplicate
submits by keeping some sort of transaction ID (e.g. as a hidden field in the
form) that you verify is not used already before you update the database. But
redirecting is easier and the extra round trip is often worth it IMHO.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html