Solved

Regarding double submission of struts form issue

Posted on 2006-11-02
5
1,103 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
Comment Utility
0
 
LVL 14

Accepted Solution

by:
boonleng earned 300 total points
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 26
JspWriter.write() and JspWriter.print() 4 75
Run the project 5 82
Can't access image with tomcat/html 6 84
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now