/** * The way to use httpclientget request * * @param username * @param password * @return NULL indicates a problem with the path being evaluated, text returns the requested data */public Stati C string Httpclientget (string username, string password) {try {//1. Open a browser httpclient client = new Defaulthttpclient ();// 2. Enter the address string path = "Http://172.22.64.156:8080/0001AndroidWebService/LoginServlet?username=" + urlencoder.encode ( username) + "&password=" + urlencoder.encode (password);//Specify the request mode HttpGet get = new HttpGet (path);//3. Hit Enter HttpResponse Response = Client.execute (get);//Gets the returned code int code = Response.getstatusline (). Getstatuscode (); if (code = = 200) {// Gets the information returned inputstream is = Response.getentity (). getcontent (); String Text = Streamutil.readstream (is); return text;} else {return null;}} catch (Exception e) {e.printstacktrace (); return null;}}
The HttpClient framework in Android sends a GET request