You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Brown, James" <ja...@ca.unisys.com> on 2004/01/15 01:42:29 UTC

Struts Validator overriding cache-control?

We have encountered a situation wherein it appears that the server-side validation provided by the struts-validator and that of ValidatorForm.validate(...) appears to be overriding the controller's nocache value.

The scenario we have encountered is follows:
  1. user enters data on a page that is backed by a subclass of ValidatorForm
  2. form is submitted but one of either server-side validation for a required field (set via the struts validator plugin) or the ValidatorForm.validate(...) method returns and ActionError.
  3. the page is redisplayed with the appropriate error message(s).
  4. the user corrects the form and submits.
  5. the subsequent (success) page is displayed.
  6. the user selects the browser's back button and receives the IE "Warning: Page has Expired" warning/error.
  7. the user refreshes the page via the F5 key or the refresh button, and the page as displayed in step 3 is redisplayed.

Our controller is set to not cache any pages via:
  <controller>
    <set-property property="nocache" value="true"/>
  </controller>

The ValidatorForm/ActionForm's scope is also set to request, thus the page should be displayed empty.

This situation only occurs if the form is submitted with data that fails server-side validation and the page is redisplayed.  In a true "success" path, the page is displayed as desired - empty.

Any ideas?

                                  Cheers,
                                  James

THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Struts Validator overriding cache-control?

Posted by Hubert Rabago <ja...@yahoo.com>.
The sequence you described is the expected behavior.
Comments below.

--- "Brown, James" <ja...@ca.unisys.com> wrote:
> We have encountered a situation wherein it appears that the server-side
> validation provided by the struts-validator and that of
> ValidatorForm.validate(...) appears to be overriding the controller's nocache
> value.
> 
> The scenario we have encountered is follows:
>   1. user enters data on a page that is backed by a subclass of ValidatorForm
>   2. form is submitted but one of either server-side validation for a required
> field (set via the struts validator plugin) or the ValidatorForm.validate(...)
> method returns and ActionError.
My guess is the form was submitted using METHOD=POST.
>   3. the page is redisplayed with the appropriate error message(s).
This page is the result of a submitted form.
>   4. the user corrects the form and submits.
>   5. the subsequent (success) page is displayed.
>   6. the user selects the browser's back button and receives the IE "Warning:
> Page has Expired" warning/error.
When the user selects the back button, he is trying to redisplay the page shown
in step 3, which can only be displayed by resubmitting the form.  IE will not
resubmit a form without informing the user, and therefore shows this warning to
tell the user.
>   7. the user refreshes the page via the F5 key or the refresh button, and the
> page as displayed in step 3 is redisplayed.
This is expected because the form that was submitted in step 2 was resubmitted by
IE to display the page requested by the user.
> 
> Our controller is set to not cache any pages via:
>   <controller>
>     <set-property property="nocache" value="true"/>
>   </controller>
> 
> The ValidatorForm/ActionForm's scope is also set to request, thus the page
> should be displayed empty.
> 
> This situation only occurs if the form is submitted with data that fails
> server-side validation and the page is redisplayed.  In a true "success" path,
> the page is displayed as desired - empty.
> 
> Any ideas?

Your user tried to redisplay the result of an errant form, and so WILL get the
page with the error message.  If you want to display an empty form, perhaps to
allow the user to enter another set of data, you can provide a link which the
user can follow for a fresh form, or display the form in step 5 along with your
"success" message.

> 
>                                   Cheers,
>                                   James



__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org