You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by abhiram <ab...@yahoo.com> on 2007/08/19 17:21:53 UTC

action being re-executed when target page is refreshed

hi i have a little problem..

  i am using struts 1.2. when i refresh the target page of a particular Action, the Action is being re-executed..

for instance.. i hav a jsp called AddAddress.jsp(which is a form for entering a new address), a form bean called AddressBookForm and an action called AddressBookAction.On success of this action, a jsp called AddressBook.jsp appears(which shows the list of existing addresses,along with the newly added one).

 the problem is that when i click "Refresh" in this(AddressBook.jsp) page, the newly added address is being added again to the database.. and so the address is being shown twice in the jsp. i want to avoid this.

this is wat i wrote in my struts-config.xml for the above action.

<form-beans >
    <form-bean name="addressBookForm" type="com.photo.struts.form.AddressBookForm" />
</form-beans>
<action
      attribute="addressBookForm"
      input="/AddAddress.jsp"
      name="addressBookForm"
      path="/AddressBookAction"
      scope="request"
      type="com.photo.struts.action.AddressBookAction">
      
      <forward name="success" path="/AddressBook.jsp"/>
      <forward name="failure" path="/failure.jsp"/>
</action> 

i just want 2 know how to stop that re-execution of the action.
please help me out.
thank you.


      abhiram




       
---------------------------------
 Why delete messages? Unlimited storage is just a click away.

Re: action being re-executed when target page is refreshed

Posted by abhiram <ab...@yahoo.com>.
that was very useful..Thank you sir. thank you very much..

Laurie Harper <la...@holoweb.net> wrote: Basically, the suggestion is to send a redirect after processing the 
form submission. Just set redirect="true" on the forward mapping for the 
page you show after handling the form.

L.

abhiram wrote:
> ! thanks for the response.. as i am new to struts, i did not understand the meaning of "submit and redirect that will change the URL in the browser and --"
> 
> could you xplain a bit more clearly ?
> 
> Nuwan Chandrasoma  wrote: Hi,
> 
> use the struts token to avoid multiple form submits or else do something 
> like submit and re-direct, that will change the URL in the browser and 
> will not all the same action mapping again.
> 
> Thanks,
> 
> Nuwan
> 
> abhiram wrote:
>> hi i have a little problem..
>>
>>   i am using struts 1.2. when i refresh the target page of a particular Action, the Action is being re-executed..
>>
>> for instance.. i hav a jsp called AddAddress.jsp(which is a form for entering a new address), a form bean called AddressBookForm and an action called AddressBookAction.On success of this action, a jsp called AddressBook.jsp appears(which shows the list of existing addresses,along with the newly added one).
>>
>>  the problem is that when i click "Refresh" in this(AddressBook.jsp) page, the newly added address is being added again to the database.. and so the address is being shown twice in the jsp. i want to avoid this.
>>
>> this is wat i wrote in my struts-config.xml for the above action.
>>
>>
>>     
>>
>>
>>       attribute="addressBookForm"
>>       input="/AddAddress.jsp"
>>       name="addressBookForm"
>>       path="/AddressBookAction"
>>       scope="request"
>>       type="com.photo.struts.action.AddressBookAction">
>>       
>>       
>>       
>>  
>>
>> i just want 2 know how to stop that re-execution of the action.
>> please help me out.
>> thank you.
>>
>>
>>       abhiram
>>
>>
>>
>>
>>        
>> ---------------------------------
>>  Why delete messages? Unlimited storage is just a click away.
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
>        
> ---------------------------------
>  Once upon a time there was 1 GB storage in your inbox. Click here for happy ending.


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




      abhiram




       
---------------------------------
 Bollywood, fun, friendship, sports and more. You name it,  we have it.

Re: action being re-executed when target page is refreshed

Posted by Laurie Harper <la...@holoweb.net>.
Basically, the suggestion is to send a redirect after processing the 
form submission. Just set redirect="true" on the forward mapping for the 
page you show after handling the form.

L.

abhiram wrote:
> ! thanks for the response.. as i am new to struts, i did not understand the meaning of "submit and redirect that will change the URL in the browser and --"
> 
> could you xplain a bit more clearly ?
> 
> Nuwan Chandrasoma <my...@gmail.com> wrote: Hi,
> 
> use the struts token to avoid multiple form submits or else do something 
> like submit and re-direct, that will change the URL in the browser and 
> will not all the same action mapping again.
> 
> Thanks,
> 
> Nuwan
> 
> abhiram wrote:
>> hi i have a little problem..
>>
>>   i am using struts 1.2. when i refresh the target page of a particular Action, the Action is being re-executed..
>>
>> for instance.. i hav a jsp called AddAddress.jsp(which is a form for entering a new address), a form bean called AddressBookForm and an action called AddressBookAction.On success of this action, a jsp called AddressBook.jsp appears(which shows the list of existing addresses,along with the newly added one).
>>
>>  the problem is that when i click "Refresh" in this(AddressBook.jsp) page, the newly added address is being added again to the database.. and so the address is being shown twice in the jsp. i want to avoid this.
>>
>> this is wat i wrote in my struts-config.xml for the above action.
>>
>>
>>     
>>
>>
>>       attribute="addressBookForm"
>>       input="/AddAddress.jsp"
>>       name="addressBookForm"
>>       path="/AddressBookAction"
>>       scope="request"
>>       type="com.photo.struts.action.AddressBookAction">
>>       
>>       
>>       
>>  
>>
>> i just want 2 know how to stop that re-execution of the action.
>> please help me out.
>> thank you.
>>
>>
>>       abhiram
>>
>>
>>
>>
>>        
>> ---------------------------------
>>  Why delete messages? Unlimited storage is just a click away.
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
>        
> ---------------------------------
>  Once upon a time there was 1 GB storage in your inbox. Click here for happy ending.


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


Re: action being re-executed when target page is refreshed

Posted by abhiram <ab...@yahoo.com>.
! thanks for the response.. as i am new to struts, i did not understand the meaning of "submit and redirect that will change the URL in the browser and --"

could you xplain a bit more clearly ?

Nuwan Chandrasoma <my...@gmail.com> wrote: Hi,

use the struts token to avoid multiple form submits or else do something 
like submit and re-direct, that will change the URL in the browser and 
will not all the same action mapping again.

Thanks,

Nuwan

abhiram wrote:
> hi i have a little problem..
>
>   i am using struts 1.2. when i refresh the target page of a particular Action, the Action is being re-executed..
>
> for instance.. i hav a jsp called AddAddress.jsp(which is a form for entering a new address), a form bean called AddressBookForm and an action called AddressBookAction.On success of this action, a jsp called AddressBook.jsp appears(which shows the list of existing addresses,along with the newly added one).
>
>  the problem is that when i click "Refresh" in this(AddressBook.jsp) page, the newly added address is being added again to the database.. and so the address is being shown twice in the jsp. i want to avoid this.
>
> this is wat i wrote in my struts-config.xml for the above action.
>
> 
>     
> 
> 
>       attribute="addressBookForm"
>       input="/AddAddress.jsp"
>       name="addressBookForm"
>       path="/AddressBookAction"
>       scope="request"
>       type="com.photo.struts.action.AddressBookAction">
>       
>       
>       
>  
>
> i just want 2 know how to stop that re-execution of the action.
> please help me out.
> thank you.
>
>
>       abhiram
>
>
>
>
>        
> ---------------------------------
>  Why delete messages? Unlimited storage is just a click away.
>   


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



       
---------------------------------
 Once upon a time there was 1 GB storage in your inbox. Click here for happy ending.

Re: action being re-executed when target page is refreshed

Posted by Nuwan Chandrasoma <my...@gmail.com>.
Hi,

use the struts token to avoid multiple form submits or else do something 
like submit and re-direct, that will change the URL in the browser and 
will not all the same action mapping again.

Thanks,

Nuwan

abhiram wrote:
> hi i have a little problem..
>
>   i am using struts 1.2. when i refresh the target page of a particular Action, the Action is being re-executed..
>
> for instance.. i hav a jsp called AddAddress.jsp(which is a form for entering a new address), a form bean called AddressBookForm and an action called AddressBookAction.On success of this action, a jsp called AddressBook.jsp appears(which shows the list of existing addresses,along with the newly added one).
>
>  the problem is that when i click "Refresh" in this(AddressBook.jsp) page, the newly added address is being added again to the database.. and so the address is being shown twice in the jsp. i want to avoid this.
>
> this is wat i wrote in my struts-config.xml for the above action.
>
> <form-beans >
>     <form-bean name="addressBookForm" type="com.photo.struts.form.AddressBookForm" />
> </form-beans>
> <action
>       attribute="addressBookForm"
>       input="/AddAddress.jsp"
>       name="addressBookForm"
>       path="/AddressBookAction"
>       scope="request"
>       type="com.photo.struts.action.AddressBookAction">
>       
>       <forward name="success" path="/AddressBook.jsp"/>
>       <forward name="failure" path="/failure.jsp"/>
> </action> 
>
> i just want 2 know how to stop that re-execution of the action.
> please help me out.
> thank you.
>
>
>       abhiram
>
>
>
>
>        
> ---------------------------------
>  Why delete messages? Unlimited storage is just a click away.
>   


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