File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
It's not a secret anymore!