This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Getting confuse on Struts action call when I click back button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Getting confuse on Struts action call when I click back button" Watch "Getting confuse on Struts action call when I click back button" New topic
Author

Getting confuse on Struts action call when I click back button

Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
If I do any operation, that means send a request to struts action
Ex: /emailFriend.do is called and sent an email successfully and then the next page is displayed(forward success). (the URL bar is showing xxx/emailFriend.do).

Now from this page, I clicked on one link to another page and went. from that page I click on browser back button then once again /emailFriend.do is called and once again the email is sent. this is absolutely wrong. how can I avoid this?


Thanks,
Kumar
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
For the forward that is used immediately after the email is sent, specify redirect="true". This will make it so the URL bar does not show as xxx/emailFriend.do, and therefore pressing the back button will never cause the email to be sent.


Merrill
Consultant, Sima Solutions
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
thank you merill,

I did the same earlier and working successfully in my server (IBM WAS 6.0), when I deployed my application in test server (same version), I see the browser exceptions saying can not find resource /xxx/xxx/EmailConfirmation.jsp", but the email has sent successfully?

Do i need to do any changes in admin console of WAS?

Now I did some other way to avoid double submission

i.e. I put a hidden field with current time millis and I m verifying before doing the operation in action class. Now its not doing recurring and it simply avoiding. working good. is that ok?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Getting confuse on Struts action call when I click back button
 
Similar Threads
html submit button javascript issue
Back button of the browser
Question about back button in browser
html:link Submitting form
My First Struts App