On 2/9/06, fea jabi <[EMAIL PROTECTED]> wrote:
> I my JSP I am having a button "Add", which adds a row to the table when
> clicked and this code is in DispatchAction. i.e adding one more object to my
> table List.
>
> Everything works fine.
>
> When I click on the Refresh on the toolbar of the browser, I am seeing that
> it tries to execute this Add method, and adding one more row.
>
> why is that? How to prevent the same?

Because it is not "refresh", it is "reload". Browser cannot refresh a
page, but it can resend the request that generated this page. Thus,
browser resends your last POST request which calls your
DispatchAction.

Your choices:
* to use token. Browser will still resend a request, but you can check
whether it is a resubmission, thus you can prevent calling your
method. This will be more complex for DispatchAction, you need to
check token before your handler is called.

* to use redirection to your result page. See
http://www.theserverside.com/articles/article.tss?l=RedirectAfterPost
and http://www.theserverside.com/articles/article.tss?l=RedirectAfterPost2
for possible implementation.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to