Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Form Tokens

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jsp form which has two html:submit buttons 'save' and 'save and add more'. Both submit the form data except that the save button loads another page and save and add more save the data but remains on that very page for more data to be inserted if needed.

I have used saveToken when coming to add page(which has these two buttons) to prevent resubmission of data when going back and clicking on save or when pressing F5.

How do I go about doing the same if one clicks on save and add more button.
If i use tokens then i am not able to save data for the second time when clicked on save and add more as the same page loads AND if i don't use token then pressing F5 after saving data for the first time would re submit the form and there would be duplicate data?
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would resetToken on each call rectify this issue?
 
Nicolas Flammel
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
resetToken after performing the insertion does the work for first time only. After that even the save button doesn't submit the form data nor does save and add more.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like you are only reseting the Token in the prepare action that forwards to the JSP.


What you need is to reset and save the Token in the Action that the form submits to.

//save the new token
resetToken(request);
saveToken(request);
 
I child proofed my house but they still get in. Distract them with this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic