0

I am struck in problem....I have link in an anchor tag which is mapped to an action and when I click on that on that link it will display all the rows of the one of the table's data from database...and in my jsp I am using s2 Iterator tag to display contents.So when I refresh that page again that action is executing which results in repeated data is getting displayed in jsp page....I came to know that in forms we can use token tag to do this... but I want it using anchor tag please help me.

struts.xml code:

<action name="displayMails" class="com.money.action.DisplayMailAction"> 
  <result name="SUCCESS" type="redirect"> </result> 
</action>
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Akshobhya
  • 169
  • 2
  • 16

1 Answers1

0
<html>
    <head>
        <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
        <script>
            $(document).ready(function() { 
                window.history.pushState("","", location.href); 
            });
        </script>
    </head>
    <body>
        <!-- STUFF -->
    </body>
</html>

It works on HTML5 browsers only, if you are targeting old Internet Explorers, it won't.

Edit: added CDN for jQuery, in case it wasn't clear...

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • [It is the URL of your current page](http://www.w3schools.com/jsref/prop_loc_href.asp). This trick is basically saying the browser's history that the last page was not coming from a post (with its parameters), but that was opened normally. This way, pressing F5 won't trigger any double submission. It has some side-effects but it should work in the most of the cases... now try it ;) – Andrea Ligios Jul 31 '13 at 10:21
  • I tried using below code $(document).ready(function() { window.history.pushState("","","localhost:8084/www.moneye.in/Inbox.jsp"); }); but still not working...please guide me any other way to do this? – Akshobhya Jul 31 '13 at 11:03
  • First: leave `location.href`, don't manually put addresses, it is "automatic"; Second: you of course will need to import jQuery, by CDN or including jQuery JS file and import in your page (for the `$(document).ready` part); otherwise, put the script with the only `history.pushState()` at the end of the body. – Andrea Ligios Jul 31 '13 at 14:26
  • Do you still have problems ? Could you accept the answer if it helped? – Andrea Ligios Sep 20 '13 at 12:25