* (e.g. from a DOM parser or HTML Tidy)
   *
   * @return a form filled with values or null, if no form handler was found
   */
  public ExtendedURL fillForm(URL baseURL, Element form) {
    ExtendedURL eurl = new ExtendedURL();
    String formURL = form.getAttribute("action");
    String type = form.getAttribute("method");
    FormHandler handler;
    URL absoluteFormURL = null;
    try {
      absoluteFormURL = new URL(baseURL, formURL);
    } catch( MalformedURLException e) {
      log.info("MalformedURLException in fillForm(): "+e.getMessage());
    }
    if (! form.getNodeName().equals("form")) {
      log.error("not a form !");
      return null;
    }
    handler = getFormHandler(absoluteFormURL.toString());
    if (handler == null) {
      log.debug("found no form handler for URL "+formURL);
      return null;
    }
    if (type.equalsIgnoreCase("get")) {
      eurl.setRequestMethod(HttpConstants.GET);
    } else if (type.equalsIgnoreCase("post")) {
      eurl.setRequestMethod(HttpConstants.POST);
    } else if (type.equals("")) {
      // workaround for sites that have no "action" attribute
      // in their forms, like Google :-(
      eurl.setRequestMethod(HttpConstants.GET);
    } else {
      log.debug("method "+type+" unknown");
      return null;
    }
    try {
      eurl.setURL(absoluteFormURL);
    } catch (Exception e) {
      log.debug("error calculating URL: "+e.getMessage());
    }
    // clear the old data in this form handler
    handler.clearValues();
    // okay, now fill the form fields ...
    collectInputFields(form, handler);
    eurl.setParams(handler.getParamString());
    
    return eurl;
  }