• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Form Submitted Twice

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic