Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

please observe this snippet

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


please ignore servlet and bean codes used in this application.my question i s ,this will disply one form and if i submit it will go for validation first then go to servlet which then store in database.so i entered the 10 records.in sql prompt it shows 10 rows created.

now my problem started ,if i came to form agin and press the F5 key(refresh) button then go to sql prompt and if we see the no of records created is 11 records.why it is happening like this .how to restrict the control doesn't goto database.

plese give me the kind reply earliest.

cheers,
babu.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too much code.
Irrelevant code in any case.

When you "refresh" a page, you send to the browser the exactly the same request you sent it last time.
If it is a "save" request, then it runs the save code again.

One common approach to prevent this is that after a "save" request, you redirect to a "display" page. Then if the user refreshes that page, they only refresh the "display" request, not the save request.
It makes it a bit harder for them to screw things up with reloading pages anyway.

An article on the subject:
http://www.theserverside.com/patterns/thread.tss?thread_id=20936
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
briefly my question is-My form data is submitting to database through controller.
if i press keyboard f5 button again the same data is submitting to the database.

for to solve that i used

cache-control,pragma headers used in jsp.but now also same form data is submitted to database.

i want to restrict that duplicate submittion.

how it is?

cheers,
babu.
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stefan answered your question in his 3rd paragraph.
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic