Solved

Regarding double submission of struts form issue

Posted on 2006-11-02
5
1,110 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Limiting the number of characters a user can type in a text field 6 65
print map entry 34 75
web application structure 18 116
by zero exception 10 70
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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