This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes doPost() called twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "doPost() called twice" Watch "doPost() called twice" New topic

doPost() called twice

lisa m

Joined: Aug 05, 2002
Posts: 4
I am seeing a problem in my servlet where the doPost() method is firing off twice, right in a row. It doesn't happen consistantly, however. Just every once in awhile. Usually after it happens, I'll try it again and it will only fire off once.
The first time doPost() is called, it contains all the parameters from the form, including the information from the submit buttons. The second time, it contains everything except the information from the submit button.
Does anyone have any suggestions on what might be causing this? Any input would be greatly appreciated.
Ronald Francis
Ranch Hand

Joined: Aug 02, 2001
Posts: 30
One usual problem is hitting the submit button multiple times (before the browser gets a chance to remove the page)..
Juanjo Bazan
Ranch Hand

Joined: Feb 04, 2002
Posts: 231
Try to avoid the problem using javascript in the client side and/or storing some state info in session and validating in your servlet.
I agree. Here's the link:
subject: doPost() called twice
Similar Threads
From doPost() to doGet()?
How does upload multiple files work
difference between doGet() and DoPost()
action getting called twice for first hit after server restart
dopost() fires every 5 minutes