• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

preventing multiple form submission

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have one form which do some task like submitting contactquery(doubts).i am not intended to process the same form like giving same query multiple times.and also user clicks browser's back button form page should expires.Iwant to write code to action class like
saveTokens.please explain this
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to aviod resubmitting the page using the browser back button, this is what we can do.

1. On load of page(in the action class method that you call while loading the page) ,
call this method : saveToken(request)

2. On submitting the page(in the action class method that you call when submitting the page), before you start processing the the form elements(contacts infromation in your case),
call this method: isTokenValid(request)
Ex:
if(!isTokenValid(request)){
return mapping.findForward("displayReSubmitError");
}

3. At the end of the method that you called on submitting the page, (after you process the contacts information),
call this method: resetToken(request)
[ December 27, 2007: Message edited by: Vani D Bandargal ]
 
npk chowdary
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vani D Bandargal
thank you very much for your valuable information.and may i know the use of using resettokens(request)
thanks again
 
Vani Bandargal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
restToken basically invalidates the current token assigned to the page. so, if sombody tries to resubmit the page using the browser back button, since the restToken already invalidated the token assigned that page, it will not be processed.
 
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic