0

I am using struts 2 and i want to avoid the duplicate form submission when clicking on refresh button...After getting the result from the Action class, i am coming back to the same jsp and it holds the value entered and also the message that it has been successfully submitted but the problem is that when i refresh the page..it again tries to submit the request....for that i am trying to use Token Interceptor available in struts 2...but i think I'm missing something...

<package name="FOCAccept" extends="struts-default">
    <action name="focSubmitRequest" class="bpel.invoke.action.FOCAcceptAction" method="execute">
        <interceptor-ref name="token"/>
        <result name="invalid.token">/postfocaccept.jsp</result>
        <result name="input">/postfocaccept.jsp</result>
        <result name="success">/postfocaccept.jsp</result>
        <result name="failure">/postfocaccept.jsp</result>
        <result name="invalid" type="redirectAction">LogoutCred.action</result>
    </action>
</package>
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
Pawan Kumar
  • 522
  • 4
  • 9
  • 29

1 Answers1

-1

I have use this and it is working fine for me...at anyhow all it's matter is the output. i have added this in the jsp and when i presses the refresh button it does not hit the controller and also makes the entered field value empty..

here is the code...... $(document).bind('keypress keydown keyup', function(e) {
if(e.which === 116) { $("#submitRequest_pon").val(""); $(".errorMessage").html(""); return false; } if(e.which === 82 && e.ctrlKey) {
return false; } });

Pawan Kumar
  • 522
  • 4
  • 9
  • 29
  • ... Your solution is to hijack normal browser functionality, when there's a well-established pattern to solve the problem?! – Dave Newton Oct 31 '13 at 14:58
  • thnaks for the reply...but how 2 do that..i tried with Token interceptor but i failed...could you please give a code example... – Pawan Kumar Nov 01 '13 at 08:28
  • i have added in my jsp and you can see my configuration above in struts.xml...and as a clik any action on that particular jsp...it shows a error msg stating the token is invalid please retry again... – Pawan Kumar Nov 01 '13 at 12:54