Public static void main (string [] ARGs) {<br/> httpclient client = new httpclient (); <br/> namevaluepair [] namevaluepairs ={< br/> New namevaluepair ("username", "AAA"), <br/> New namevaluepair ("passwd ", "123456") <br/>}; <br/> postmethod = new postmethod ("Logon URL"); <br/> postmethod. setrequestbody (namevaluepairs); <br/> int stats = 0; <br/> try {<br/> stats = client.exe cutemethod (postmethod); <br />} Catch (httpexception e) {<br/> E. printstacktrace (); <br/>}catch (ioexception e) {<br/> E. printstacktrace (); <br/>}< br/> postmethod. releaseconnection (); // it is best to release the previous resources <br/> cookiespec = cookiepolicy. getdefaspec SPEC (); <br/> cookie [] cookies = cookiespec. match ("Domain Name", 80/* port */, "/", false, client. getstate (). getcookies (); <br/> for (COOKIE: cookies) {<br/> system. out. println (cook IE. getname () + "#" + Cookie. getvalue (); <br/>}</P> <p> httpmethod = NULL; <br/> string encode = "UTF-8"; // page encoding, by access page changes <br/> string Referer = "http: // domain name"; // http://www.163.com <br/> method = new getmethod ("url2 "); // subsequent operations <br/> method. getparams (). setparameter ("HTTP. useragent "," Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) "); <br/> method. setRequestHeader ("Referer", Referer); </P> <p> client. getparams (). Setcontentcharset (encode); <br/> client. getparams (). setsotimeout (300000); <br/> client. getparams (). setparameter (httpmethodparams. retry_handler, new defaulthttpmethodretryhandler (10, true); </P> <p> try {<br/> stats = client.exe cutemethod (method ); <br/>} catch (httpexception e) {<br/> E. printstacktrace (); <br/>}catch (ioexception e) {<br/> E. printstacktrace (); <br/>}< br/> If (Stats = httpstatus. SC _ OK) {<br/> system. Out. println ("submitted successfully! "); </P> <p >}< br/>}