title: how to submit form using jsoup
body: <p>I want to submit form from a webpage which has several forms.  I want to submit this form below in particular.  </p>
  
  <pre><code>&lt;form action="realDisplay.asp" method="post" name="Search" onSubmit="return validate(this); return submitForm();" target="_blank"&gt;
                 &lt;table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" bordercolor="#FFFFFF"&gt;
                &lt;tr&gt;
                   &lt;td width="127" class="style62" align="right"&gt;Parcel ID&lt;/td&gt;
                  &lt;td width="286"&gt;
                    &lt;div align="center"&gt;
                      &lt;table border="0" cellpadding="0" cellspacing="0" width="100%%" align="center"&gt;
                        &lt;tr&gt;
                          &lt;td align="left" class="style62"&gt;&amp;nbsp;
                          &lt;input name="rePID" size="15" maxlength="15" value=""&gt;
                           &lt;br&gt;
                            &lt;font class="style65"&gt;( 12 123 12 123)&lt;/font&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                      &lt;/table&gt;
                    &lt;/div&gt; 
                  &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                   &lt;td width="127" class="style62" align="right"&gt;Partial Parcel ID&lt;/td&gt;
                  &lt;td width="286"&gt;
                    &lt;div align="center"&gt;
                      &lt;table border="0" cellpadding="0" cellspacing="0" width="100%%" align="center"&gt;
                        &lt;tr&gt;
                          &lt;td align="left" class="style62"&gt;&amp;nbsp;
                          &lt;input name="rePartialPID" size="15" maxlength="15" value=""&gt;
                           &lt;br&gt;
                            &lt;font class="style65"&gt;( 12 123)&lt;/font&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                      &lt;/table&gt;
                    &lt;/div&gt; 
                  &lt;/td&gt;
                  &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td class="style62" align="right"&gt;Address&lt;/td&gt;
                  &lt;td class="style62" align="left"&gt;&amp;nbsp;
                    &lt;input name="Address" size="38" maxlength="50" value=""&gt;
                  &lt;/td&gt;
                &lt;/tr&gt;
                 &lt;tr&gt;
                  &lt;td class="style62" align="right" nowrap="nowrap"&gt;Partial Street Name&lt;/td&gt;
                  &lt;td class="style62" align="left"&gt;&amp;nbsp;
                    &lt;input name="streetName" size="38" maxlength="50" value=""&gt;
                  &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td class="style62" align="right" nowrap="nowrap"&gt;Owner Name&lt;/td&gt;
                  &lt;td class="style62" align="left"&gt;&amp;nbsp;
                    &lt;input name="OwnerName" size="30" maxlength="50" value=""&gt;   
                  &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td colspan="2"&gt;&lt;br /&gt;&lt;font class="style64"&gt;Insert&lt;/font&gt;
                    &lt;font class="style65"&gt;&lt;u&gt;Either&lt;/u&gt;&lt;/b&gt;&lt;/font&gt;&lt;font class="style64"&gt;&amp;nbsp;a&lt;/font&gt;:&lt;br&gt;
                   &lt;br&gt;
                   &lt;table align="center" border="1" cellspacing="0" cellpadding="3" bgcolor="#E8E8E8"&gt;
                      &lt;tr&gt;
                        &lt;td align="left"&gt;&lt;img src="Images/arrow_1.gif" width="9" height="7" vspace="0" hspace="8"&gt;&lt;/td&gt;
                        &lt;td class="style75" align="left"&gt;
                        &lt;a class="nav4" href="GlossaryTermWin.htm#ParcelID" onClick="NewWindow(this.href,'PARCELID','635','635','yes');return false;"&gt;
                       Parcel ID&lt;/a&gt; , or Partial Parcel ID&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                        &lt;td&gt;
                        &lt;img src="Images/arrow_1.gif" width="9" height="7" vspace="0" hspace="8"&gt;&lt;/td&gt;
                        &lt;td class="style75" align="left"&gt;Address (eg. 123 main), or&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                        &lt;td class="style75" align="left"&gt;
                        &lt;img src="Images/arrow_1.gif" width="9" height="7" vspace="0" hspace="8"&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
                        &lt;td class="style75"&gt;Partial Street Name (eg. main), or&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                        &lt;td class="style75"&gt;
                        &lt;img src="Images/arrow_1.gif" width="9" height="7" vspace="0" hspace="8"&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
                        &lt;td class="style75" align="left"&gt;Owner Name &lt;br /&gt;(eg. LastName,FirstName &lt;br /&gt;or
                                Partial Owner Name)&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt; &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                   &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt;
                      &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td height="26" colspan="2" align="center"&gt;
                  &lt;input type="image" valign="top" name="Submit" value="Search" src="images/search.jpg" align="top" alt="Search by either the Parcel ID or Address or Owner Name that is associated by the real estate information."&gt;
                  &lt;a href="javascript:document.forms[0].reset()" border="0"&gt;&lt;img src="images/reset.jpg" align="top" border="0" alt="Reset the values on this page." onClick="ResetForm()"&gt;&lt;/a&gt;&lt;/td&gt;
                &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/form&gt;&lt;/td&gt;
  </code></pre>
  
  <p>My Java Code looks like this:</p>
  
  <pre><code>Document doc = Jsoup.connect("http://web.somewebsite.asp")
                     .data("rePID", "15 197 14 007")
                     .post();
  </code></pre>
  
  <p>I want to able to view the webpage that comes up after I submit this form, and also view the text content of that page, and also want to get url as well.  </p>
  
  <p>What would I have to do in my Java code to make sure that submit request was submitted and view the content of next page after submitting the form.  </p>
  
  <p>I was able to submit form using Htmlunit, you can search the web and download the package.</p>
  
  <pre><code>import com.gargoylesoftware.htmlunit.html.HtmlForm;
  import com.gargoylesoftware.htmlunit.html.HtmlPage;
  import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
  import com.gargoylesoftware.htmlunit.html.HtmlImageInput;
  import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
  import com.gargoylesoftware.htmlunit.BrowserVersion;
  import com.gargoylesoftware.htmlunit.WebClient;
  
  WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10);
  final HtmlPage searchPage = webClient.getPage("http://web.somewebsite.asp"); 
  
      final HtmlForm form = searchPage.getFormByName("Search"); 
      final HtmlTextInput textField = form.getInputByName("rePID");
      textField.setValueAttribute("15 197 14 007");
      final HtmlImageInput button = form.getInputByName("Submit"); 
      HtmlPage searchResultPage = (HtmlPage)button.click();
  </code></pre>