3

Hi am design on page with strut action class with method. when I called method its done properly and got success result. But I have problem when I refresh what success page its again submit the previous page values in database. how to avoid this one.

my first jsp page form

<form name="manualorder" action="manual_order" onsubmit="return validation();">

struts.xml

 <action name="purchaseorder" class="materialTypeMasterAction" method="createorder" >
    <result name="success">/pages/procurement/PurchaseOrder.jsp</result>
    </action>



    <action name="manual_order" class="materialTypeMasterAction" method="enquiry_process">
    <result name="success">/pages/procurement/success.jsp</result>
    </action>

when i refresh this success page its again call enquiry_process method and submit previous value which i created in createorder method in action first one.

Synchro
  • 35,538
  • 15
  • 81
  • 104

2 Answers2

3

YOu can solve your problem using redirect action. Just change your struts file as below ( i have added one more action for success:

<action name="purchaseorder" class="materialTypeMasterAction" method="createorder" >
    <result name="success">/pages/procurement/PurchaseOrder.jsp</result>
</action>
<action name="SuccessAction" class="SuccessPage">

  <result name="success">/pages/procurement/success.jsp</result>

<action name="manual_order" class="materialTypeMasterAction" method="enquiry_process">
        <result type="redirectAction">SuccessAction</result>
</action>

Please do not forget to create SuccessPage class

Butani Vijay
  • 4,181
  • 2
  • 29
  • 61
0

use post-redirect-get pattern.

On success, redirect to the "success" page. That way if the user refreshes, they just get that same page again.

See this link Preventing Form Resubmission (due refreshing) and also see Preventing Double Form Submission This may help you

rachana
  • 3,344
  • 7
  • 30
  • 49
  • @user3805315 I have updated my answer and added one link that link may help you – rachana Jul 04 '14 at 12:03
  • after redirect success.jsp. i try to refresh that success.jsp page that time its happen. what ever that jsp page give in if i refresh that page it will submit duplicate values. – user3805315 Jul 04 '14 at 12:03