</pre><pre name= "code" class= "Java" >//this article does not <span style= "font-family:arial, Helvetica, Sans-serif;" >username, password for verification, please add this part of the reader, such as to determine whether it is empty </span>
public class Httputils {private static final String tag= "httputils"; static string Pathstring=null;public httputils () {//T ODO auto-generated Constructor stub};p ublic static void Sendpost (String username,string password) {log.d (TAG, username); LOG.D (TAG, password);
Get request <span style= "font-family:arial, Helvetica, Sans-serif;" >192.168.0.179:8080 the address for Tomcat, everyone is different, remember to modify </span>
<span style= "font-family:arial, Helvetica, Sans-serif;" > //The entire get URI </span><span style= "font-family:arial, Helvetica, Sans-serif;" >192.168.0.179:8080</span><span style= "font-family:arial, Helvetica, Sans-serif;" >?</span><span style= "font-family:arial, Helvetica, Sans-serif;" >username=admin&password=123</span><span style= "font-family:arial, Helvetica, Sans-serif;" ></span><span style= "font-family:arial, Helvetica, Sans-serif;" ></span>pathstring= "Http://192.168.0.179:8080/Myweb/Webdo" + "?" + "Username=" +username+ "&" + "password=" +password; LOG.D (TAG, pathstring);
Create Httpclienthttpclient client=new defaulthttpclient (); Create GET request HttpGet get=new HttpGet (pathstring); try {
HttpResponse Response=client.execute (GET);
Gets the returned result 200 for the request to succeed. if (Response.getstatusline (). Getstatuscode () ==200) {log.d (TAG, "sucess!!");}} catch (Clientprotocolexception e) {//Todo auto-generated catch Blocke.printstacktrace ();} catch (IOException e) {//TODO Auto-generated catch Blocke.printstacktrace ();}};}
Login Interface Andriod Simple HTTP GET request (with server side) two