Solved

Regarding double submission of struts form issue

Posted on 2006-11-02
5
1,108 Views
Last Modified: 2012-06-21
Hi Experts,
I have a struts form which I have to stop double submission thru saveToken..
but I am not able to understand the functionality of saveToken and isTokenvalid function of struts...

Pls help

Regards,
dojjol


0
Comment
Question by:dojjol
  • 2
  • 2
5 Comments
 
LVL 10

Assisted Solution

by:jaggernat
jaggernat earned 200 total points
ID: 17858221
0
 
LVL 14

Accepted Solution

by:
boonleng earned 300 total points
ID: 17863496
When saveToken() method is invoked, struts will generate a unique key/token and store it into httpsession. The unique key will also be stored as a hidden field (form submition) or as a parameter in url link.

Once the form submitted, the method isTokenValid() will verify the submitted unique key (the hidden field) with the unique key value stored in httpsession. If both value match means 1st time submittion, so will call removeToken() to remove the unique key from httpsession.

If the user refesh page or resubmit the form using back button, the isTokenValid() will trigger again, coz the unique key has been removed from httpsession, the verification fail. This mean the form is resubmitted.

Hope this able to help you understand.

Regards,
Boon Leng
0
 

Author Comment

by:dojjol
ID: 17865120
Hi,

It will be really helpful for me if I can have any sample Action class processing theses functions..

Thanks in advance,
Dojjol

0
 
LVL 14

Expert Comment

by:boonleng
ID: 17866091
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17867071
the link i posted above has 4 pages. did you go through the second page? It has all the code.
Second page :
http://www.javaworld.com/javaworld/javatips/jw-javatip136.html?page=2
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question