• Post Reply Bookmark Topic Watch Topic
  • New Topic

Confirm form resubmission?  RSS feed

 
Ryan McClain
Ranch Hand
Posts: 153
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just wrote a simple servlet with a doPost() implementation (no doGet()).

I fill out a simple HTML form with one textfield and two radio buttons. When I press the submit button, it takes me to my servlet that prints out my submitted name and my radio button choices.
So now my browser is sitting at the servlet URL with the results on the page:

name: Ryan (text field)
year: Second Year (radio button)
specialization: Application Development (radio button)

What exactly happens when I press F5 on this page and I say 'Yes' to Chrome's "Confirm form resubmission"?
I was surprised, because the browser remembered my previously entered request parameters, when I know that these should be destroyed upon exiting the servlet's HTTP method.

So, this is what I assume:
What the resubmission does is re-enter exactly the same request parameters back into the previous form and it hits the submit button for me, which brings me back to the page of the servlet (/Choice).

I'm not sure, so if anyone knows what happens on forced form resubmission (F5)?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does exactly that: it submits the same request -including all form parameters- again. All browser work this way, not just Chrome. That's why you should implement the PRG pattern for form submissions.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might also be interested in this article which goes into more detail.
 
Ryan McClain
Ranch Hand
Posts: 153
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting stuff.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!