request sent twice

  • Hartmut Haas

    Hartmut Haas - 2008-05-28

    This problem occurs with httpunit 1.7, not with 1.6.2 .
    The code ic pretty simple, just submit a button:
        form.setParameter(edName, user);
        form.setParameter(edPwd, password);
        SubmitButton sb = form.getSubmitButton(pbAn);
        resp = form.submit(sb);
    The same request is sent twice to the server.

    Debugging webform.class:

        public WebResponse submit( SubmitButton button, int x, int y ) throws IOException, SAXException {
            WebResponse result=null;
          if (button==null || button.doOnClickSequence(x, y)) {
              result= doFormSubmit( button, x, y );
          } else {
          return result;

    the request is submitted in button.doOnClickSequence *AND* in doFormSubmit.
    Scripting is disabled by

    • Dominique Schneider

      I can confirm that erronous behaviour.  As stated the point here is that in a normal form submit the doFormSubmit method is called twice through the WebForm.submit(SubmitButton button, int x, int y) method. Once explicitly and another a second time through the button.doOnClickSequence call in the if condition.

      Here is a stacktrace upon a form submit in 1.7:

      Thread [main] (Suspended)
              WebForm.doFormSubmit(SubmitButton, int, int) line: 143
              SubmitButton.doButtonAction(int, int) line: 69
              SubmitButton(Button).doOnClickSequence(int, int) line: 91
              WebForm.submit(SubmitButton, int, int) line: 107        <=== 2nd call to doFormSubmit(SubmitButton, x, y) if stack decreased
              WebForm.submit(SubmitButton) line: 93

      You can see that the first submit is triggered during the evaluation of the if condition and another time if the condition evaluates positively.

      In HttpUnit 1.6 instead of button.doOnClickSequence(x, y)) button.doOnClickEvent was used which didn't implicitly trigger a form submit.


    • Dominique Schneider


Log in to post a comment.