*
The moose likes Struts and the fly likes Form Submitted Twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Form Submitted Twice" Watch "Form Submitted Twice" New topic
Author

Form Submitted Twice

Dom Incollingo
Greenhorn

Joined: Dec 04, 2002
Posts: 7
Hello,

I'm using Struts 1.2.4 (along with the validator framework), and I've noticed that for my forms that do a Post, the action class is executed twice. I put log statements in my code to try to figure out what is happening. The sequence of events is as follows:

- User presses Update button on a JSP
- doPost method invoked (ActionServlet)
- Struts validation methods invoked
- execute method (Action class) entered
- execute method (Action class) returns forward action of Success
- processing returns to the same JSP
.........................................................................
- doGet method invoked (ActionServlet)
- Struts validation methods invoked
- execute method (Action class) entered
- processing returns to the same JSP
- web page is displayed on browser

Everything prior to the doGet looks normal. I can't understand why the JSP submits a Get request when it should display. The method specified in the JSP's form (there is only one form in the JSP) is a Post, not a Get. The JSP does not contain any JavaScript.

Has anyone seen this problem or know what is happening here? Thanks very much for your assistance.

Dom
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
hi

Check out if ur validator function is submitting ur form and u r using the html:submit.......this happens when u have the button of the type submit and u submit in javscript function also which sends 2 requests.

As u were saying that it doesnt have any javascript , check out the code renedered by the validator framework and if ist fine just change that update to simple html:button than submit

let me know if this works
Dom Incollingo
Greenhorn

Joined: Dec 04, 2002
Posts: 7
Thanks for the reply. I didn't see your reply until today (April 4). Last night, I made a few functional changes (unrelated, I thought), and one of them seems to have solved the problem.

There were a couple work fields stored in the form bean (ActionForm), called
userAction and systemAction, that were being used to determine which
buttons to display based on what the user was trying to do. I removed
the field called systemAction..... And when I ran the next test, the
system did a doPost but did not follow that with a doGet. How this could have solved the problem, I can't even begin to imagine....

When I get home from work tonight, I'll check the code rendered by the validator framework, as you suggested. I am using html:submit for my buttons; perhaps changing them to html:buttons would also have solved the problem (and a better solution as well).

Thanks for your help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form Submitted Twice
 
Similar Threads
html:image - running into an infinite loop
ActionServlet , RequestProcessor - Flow ?
On mysterious error returned to login page?
flow of control in struts
First struts app help! Drop-down lists