You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Neil Aggarwal <ne...@JAMMConsulting.com> on 2005/02/09 08:34:18 UTC

Redirect instead of forward in action mapping

Hello:

When I set up a form in struts, I am using this action
mapping:

    <action path="/registerForm"
            type="register.RegisterAction"
            name="registerForm"
            scope="request"
            input="register.index"
            validate="true">
      <forward name="success" path="register.success"/>
    </action>

When the form is posted successfully, the user is forwarded
to a page that says their information was entered successfully.

Unfortunately, if they hit reload on that page, it will re-execute
the form and their data will be posted again.

To get around this, I use a redirect instead of forward in many
of my apps.

Is there a way to do that within struts?

Thanks,
	Neil


--
Neil Aggarwal, JAMM Consulting, (972)612-6056, www.JAMMConsulting.com
FREE! Valuable info on how your business can reduce operating costs by
17% or more in 6 months or less! http://newsletter.JAMMConsulting.com


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


RE: Redirect instead of forward in action mapping

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Bill:

I tried adding the redirect="true" parameter to my success
forward and it does not seem to have an effect.  When
I get to the success page and hit the reload button on my
browser, the form data is posted again.

You can try it by going to:
https://dev.jammconsulting.com/pricetracker/register.do
enter something (junk is OK) in the email address field
and hit the Save button.  When you get to the
success page, hit the reload button on the browser.
You will get a pop up that tells you it is resending
the information.

Here is what I have in my struts-config.xml file:
    <action path="/registerForm"
            type="register.RegisterAction"
            name="registerForm"
            scope="request"
            input="register.index"
            validate="true">
      <forward name="success" path="register.success" redirect="true"/>
    </action>

Any ideas why that did not work?

Thanks,
	Neil


--
Neil Aggarwal, JAMM Consulting, (972)612-6056, www.JAMMConsulting.com
FREE! Valuable info on how your business can reduce operating costs by
17% or more in 6 months or less! http://newsletter.JAMMConsulting.com

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Bill Siggelkow
> Sent: Wednesday, February 09, 2005 10:23 PM
> To: user@struts.apache.org
> Subject: Re: Redirect instead of forward in action mapping
> 
> 
> Set the redirect attribute on the forward to true:
> 
> <forward name="success" path="register.success" redirect="true"/>
> 
> Of course, if the success page displays data you will need to 
> make sure 
> that is is available in the session since it you will be 
> issuing a new 
> request. (You may want to look into the saveMessages(HttpSession 
> session) method).
> 
> Neil Aggarwal wrote:
> 
> > Hello:
> > 
> > When I set up a form in struts, I am using this action
> > mapping:
> > 
> >     <action path="/registerForm"
> >             type="register.RegisterAction"
> >             name="registerForm"
> >             scope="request"
> >             input="register.index"
> >             validate="true">
> >       <forward name="success" path="register.success"/>
> >     </action>
> > 
> > When the form is posted successfully, the user is forwarded
> > to a page that says their information was entered successfully.
> > 
> > Unfortunately, if they hit reload on that page, it will re-execute
> > the form and their data will be posted again.
> > 
> > To get around this, I use a redirect instead of forward in many
> > of my apps.
> > 
> > Is there a way to do that within struts?
> > 
> > Thanks,
> > 	Neil
> > 
> > 
> > --
> > Neil Aggarwal, JAMM Consulting, (972)612-6056, 
> www.JAMMConsulting.com
> > FREE! Valuable info on how your business can reduce 
> operating costs by
> > 17% or more in 6 months or less! 
> http://newsletter.JAMMConsulting.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


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


Re: Redirect instead of forward in action mapping

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Set the redirect attribute on the forward to true:

<forward name="success" path="register.success" redirect="true"/>

Of course, if the success page displays data you will need to make sure 
that is is available in the session since it you will be issuing a new 
request. (You may want to look into the saveMessages(HttpSession 
session) method).

Neil Aggarwal wrote:

> Hello:
> 
> When I set up a form in struts, I am using this action
> mapping:
> 
>     <action path="/registerForm"
>             type="register.RegisterAction"
>             name="registerForm"
>             scope="request"
>             input="register.index"
>             validate="true">
>       <forward name="success" path="register.success"/>
>     </action>
> 
> When the form is posted successfully, the user is forwarded
> to a page that says their information was entered successfully.
> 
> Unfortunately, if they hit reload on that page, it will re-execute
> the form and their data will be posted again.
> 
> To get around this, I use a redirect instead of forward in many
> of my apps.
> 
> Is there a way to do that within struts?
> 
> Thanks,
> 	Neil
> 
> 
> --
> Neil Aggarwal, JAMM Consulting, (972)612-6056, www.JAMMConsulting.com
> FREE! Valuable info on how your business can reduce operating costs by
> 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com


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