struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: Handling refresh in a web based application
Date Thu, 25 Jan 2001 19:27:08 GMT
ron talk wrote:

> Hi all,
>
> is there anyway to determine whether a repeated http request has been
> generated through a
>       - click on the refresh button on a browser
>       - through clicking the back button a the browser and re-clicking the
> link/button generating the initial request
>
> I am working on a struts based application in which I must allow the request
> to be completed if it is though going back and re clicking the link, but if
> its a simple refresh, the request is ignored.
>

There is a capability to detect repeated submits of the same form, using a
"command token" functionality.

In the Struts example application, you will note that EditRegistrationAction
(which sets up the form bean for the registration.jsp page) calls

    saveToken(request);

near the bottom.  This stores a session attribute with a transactional control
token that must be submitted on the next request in order to be valid.  Then, in
the SaveRegistrationAction (which handles the submit), we see:

    if (!isTokenValid(request)) {
        ... deal with the error ...
    }
    resetToken(request);

so that your app can do whatever is appropriate when it detects a resubmit.

No changes to the JSP pages themselves are necessary (the <html:form> tag
automatically creates a hidden variable if needed).  IMHO, transactional control
like this is a "controller" thing (in the model-view-controller paradigm), so
page authors should not have to be concerned with it.

Craig



Mime
View raw message