/** * Prepare to submit this form. A Connection object is created with the request set up from the form values. You * can then set up other options (like user-agent, timeout, cookies), then execute it. * @return a connection prepared from the values of this form. * @throws IllegalArgumentException if the form's absolute action URL cannot be determined. Make sure you pass the * document's base URI when parsing. */ public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Connection.Method.POST : Connection.Method.GET; return Jsoup.connect(action) .data(formData()) .method(method); }