Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8052619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:35:22+00:00 2026-06-05T07:35:22+00:00

After a user submits an html form (with method=post) it brings them back to

  • 0

After a user submits an html form (with method=”post”) it brings them back to the page they were on (but with some of the data changed). If the user refreshes the page, the form is submitted again. In my application this can create an illegal state (since the form data is submitted without going through verification).

How can I prevent the form from being submitted when the user refreshes the page?

Here is some sample code to give you a basic idea of what is going on:

<script type="javascript">
function verifyForm() {
//do stuff
}
...
<form onsubmit="return verifyForm();" method="post">
<input name="testing" type="text" size="8" />
<input name="save" type="submit value="Submit Form" />
</form>

Then in the JSP controller:

public class myController implements Controller
{ 
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception
{
// do stuff with the form data received in the request
}
}

There are several places I might be able to solve this problem: in the html page itself, or in the controller (using MVC pattern in jsp). So far I have found this question that almost seems to apply to my question, but doesn’t quite seem to be asking the same thing (also I am not using PHP).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:35:23+00:00Added an answer on June 5, 2026 at 7:35 am

    You need to use the PRG pattern: Post/Redirect/Get.

    Read about it here: http://en.wikipedia.org/wiki/Post/Redirect/Get

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If a website user submits an HTML form with: (1) a post method; (2)
I have a page with nothing on it but this form: <form method=post action=/sign-in>
After a user submits a form, how do you detect that the form has
User registration in my application is performed in steps. After submitting the form, some
I have a user control which contains the following code: <form id=CurrencyForm method=post runat=server>
This works in clearing in input after a user submits it via ajax on
I'm trying to figure out how to show validation errors after a user submits
I'm building a tagger. After a user submits a tag, ajax returns: {returnmessage:The Ajax
I want to have multiple multiple choices given to user after the form submit
Goal : After user saves data to my mysql DB, a JSON teaser of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.