首先,這個需要一點HTTP基礎,可以先看個書了解下,我看的《http權威指南》的前4章,后面道行不夠看不下去。
然后我們的是java.net的接口:
幾個類的API:
package com.http; import java.net.URI; import java.net.URISyntaxException; /** * Created by zhen on 2017-06-25. * 表示一個統一標志符(URI)引用 */ public class URITest { /** public final class URI extends Objectimplements Comparable<URI>, Serializable 最高級別上,字符串形式的URI引用:[scheme:]scheme-specific-part[#fragment] 不透明的URI為絕對URI,其方案部分不是以"/"開始。不透明URI無法進行進一步解析。如: mailto:java-net@java.sun.com 分成URI以"/"開始,如: http://java.sun.com/j2se/1.3 分層URI還要按照下面的語法進行下一步的解析: [scheme:][//authority][path][?query][#fragment] 針對URI實例的運算: 規范化、解析、相對化運算。 規范化 是將分層URI路徑組成中的不必要的"."和“..”移除的過程。每個“.”部分將被移除。".."部分也被移除,除非它前面有一個非".."部分 解析 是根據另一個基於URI解析某個URI的過程。例如docs/guide/collections/designfaq.html根據基本URI http://java.sun.com/j2se/1.3 解析結果為URI: http://java.sun.com/j2se/1.3/docs/guide/collections/designfaq.html 相對化 是解析的逆過程:對於任何兩個規范的URI u和v,u.relativize(u.resolve(v)).equals(v)和u.resolve(u.relativize(v)).equals(v) 標識 對於任何URI u,下面的標識有效: new URI(u.toString()).equals(u) 對於不包含冗余語法的任何URI u,比如在一個空授權前面有兩根斜線(如:file///tmp/)和主機名后面跟這一個冒號但沒有端口 (如:http://java.sun.com),以及除必須引用的字符之外不對字符編碼的情況下,下面標識也有效: new URI(u.getScheme()、 u.getSchemeSpecificPart()、 u.getFragment()) .equals(u) 在所有情況下,以下標識有效 new URI(u.getScheme()、 u.getUserInfo()、 u.getAuthority()、 u.getPath()、 u.getQuery()、 u.getFragment()) .equals(u) 如果 u 為分層的,則以下標識有效 new URI(u.getScheme()、 u.getUserInfo()、 u.getHost()、 u.getPort()、 u.getPath()、 u.getQuery()、 u.getFragment()) .equals(u) 方法: 靜態方法: static URI create(String str) 通過解析給定的字符串創建 URI。 構造: URI(String str) URI(String scheme, String ssp, String fragment) URI(String scheme, String userInfo, String host, int port, String path, String query, String fragment) URI(String scheme, String host, String path, String fragment) URI(String scheme, String authority, String path, String query, String fragment) 其他方法: int compareTo(URI that) 將此 URI 與另一個對象(也必須是 URI)進行比較。 boolean equals(Object ob) 測試此 URI 與另一對象的相等性。 String getAuthority() 返回此 URI 的已解碼的授權組成部分。 String getFragment() 返回此 URI 的已解碼的片段組成部分。 String getHost() 返回此 URI 的主機組成部分。 String getPath() 返回此 URI 的已解碼的路徑組成部分。 int getPort() 返回此 URI 的端口號。 String getQuery() 返回此 URI 的已解碼的查詢組成部分。 String getRawAuthority() 返回此 URI 的原始授權組成部分。 String getRawFragment() 返回此 URI 的原始片段組成部分。 String getRawPath() 返回此 URI 的原始路徑組成部分。 String getRawQuery() 返回此 URI 的原始查詢組成部分。 String getRawSchemeSpecificPart() 返回此 URI 原始的、特定於方案的部分。 String getRawUserInfo() 返回此 URI 的原始用戶信息組成部分。 String getScheme() 返回此 URI 的方案組成部分。 String getSchemeSpecificPart() 返回此 URI 的特定於方案的解碼部分。 String getUserInfo() 返回此 URI 的已解碼的用戶信息組成部分。 int hashCode() 返回此 URI 的哈希碼值。 boolean isAbsolute() 判斷此 URI 是否為絕對的。 boolean isOpaque() 判斷此 URI 是否為不透明的。 URI parseServerAuthority() 嘗試將此 URI 的授權組成部分(如果已定義)解析為用戶信息、主機和端口組成部分。 String toASCIIString() 以 US-ASCII 字符串形式返回此 URI 的內容。 String toString() 以字符串形式返回此 URI 的內容。 URL toURL() 根據此 URI 構造一個 URL。 規范化、相對化、解析: URI normalize() 規范化此 URI 的路徑。 URI relativize(URI uri) 根據此 URI 將給定 URI 相對化。 URI resolve(String str) 解析給定的字符串,然后在此 URI 的基礎上構造一個新的 URI。 URI resolve(URI uri) 根據此 URI 解析給定的 URI。 */ public static void main(String[] args){ // try{ // URI uri = new URI("http://www.baidu.com"); // URI uri = new URI("https", "www.baidu.com", null); // URI uri = new URI("http", "guozhen", "www.baidu.com", 80, "/index.html", "id=2", null); // URI uri = new URI("http", "127.0.0.1", "/index.html",null); // URI uri = URI.create("http://127.0.0.1:2001"); // System.out.println(uri.toString()); // }catch(URISyntaxException ex){ // ex.printStackTrace(); // } // System.out.println("規范化:\n\t" + uri.normalize().toString()); // System.out.println("相對化http://127.0.0.1:2001/book/query?id=12:\n\t" + uri.relativize(URI.create("http://127.0.0.1:2001/book/query?id=12"))); // System.out.println("解析/book/query?id=12:\n\t" + uri.resolve("/book/query?id=12")); URI uri = URI.create("http://127.0.0.1:2001/book/query?id=12"); System.out.println("方案:\t" + uri.getScheme()); System.out.println("主機:\t" + uri.getHost()); System.out.println("端口:\t" + uri.getPort()); System.out.println("路徑:\t" + uri.getPath()); System.out.println("查詢:\t" + uri.getQuery()); } } package com.http; /** * Created by zhen on 2017-06-25. * 類 URL 代表一個統一資源定位符 */ public class URLTest { /** URL類本身並不會根據RFC2396中定義的轉義機制編碼或者解碼任何URL部分。由調用方對任何需要調用URL前進行轉義的字段進行編碼,並對從URL返回的任何經過轉義的字段進行解碼。 例如,針對這兩個URL,被視為互不相等: http://foo.com/hello world/ 和 http://foo.com/hello%20world 注意,URI 類在某些特定情況下對其組成字段執行轉義。建議使用 URI 管理 URL 的編碼和解碼,並使用 toURI() 和 URI.toURL() 實現這兩個類之間的轉換。 也可以使用 URLEncoder 和 URLDecoder 類,但是只適用於 HTML 形式的編碼,它與 RFC2396 中定義的編碼機制不同。 方法: 構造: URL(String spec) URL(String protocol, String host, int port, String file) URL(String protocol, String host, int port, String file, URLStreamHandler handler) URL(String protocol, String host, String file) URL(URL context, String spec) URL(URL context, String spec, URLStreamHandler handler) 獲取URLConnection和流: URLConnection openConnection() 返回一個 URLConnection 對象,它表示到 URL 所引用的遠程對象的連接。 URLConnection openConnection(Proxy proxy) 與 openConnection() 類似,所不同是連接通過指定的代理建立;不支持代理方式的協議處理程序將忽略該代理參數並建立正常的連接。 InputStream openStream() 打開到此 URL 的連接並返回一個用於從該連接讀入的 InputStream。 其他方法: boolean equals(Object obj) 比較此 URL 是否等於另一個對象。 String getAuthority() 獲取此 URL 的授權部分。 Object getContent() 獲取此 URL 的內容。 Object getContent(Class[] classes) 獲取此 URL 的內容。 int getDefaultPort() 獲取與此 URL 關聯協議的默認端口號。 String getFile() 獲取此 URL 的文件名。 String getHost() 獲取此 URL 的主機名(如果適用)。 String getPath() 獲取此 URL 的路徑部分。 int getPort() 獲取此 URL 的端口號。 String getProtocol() 獲取此 URL 的協議名稱。 String getQuery() 獲取此 URL 的查詢部分。 String getRef() 獲取此 URL 的錨點(也稱為“引用”)。 String getUserInfo() 獲取此 URL 的 userInfo 部分。 int hashCode() 創建一個適合哈希表索引的整數。 boolean sameFile(URL other) 比較兩個 URL,不包括片段部分。 protected void set(String protocol, String host, int port, String file, String ref) 設置 URL 的字段。 protected void set(String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) 設置 URL 的指定的 8 個字段。 static void setURLStreamHandlerFactory(URLStreamHandlerFactory fac) 設置應用程序的 URLStreamHandlerFactory。 String toExternalForm() 構造此 URL 的字符串表示形式。 String toString() 構造此 URL 的字符串表示形式。 URI toURI() 返回與此 URL 等效的 URI。 */ } package com.http; /** * Created by zhen on 2017-06-25. * 抽象類URLConnection是所有類的超類,它代表應用程序和URL之間的通信鏈接。此類的實體可用於讀取和寫入此URL引用的資源。 * 通常,創建一個到URL的連接需要幾個步驟: * 1、通過在URL上調用openConnection方法創建連接對象 * 2、處理設置參數和一般請求屬性 * 3、使用connect方法建立到遠程對象的實際連接 * 4、遠程對象變為可用。遠程對象的頭字段和內容變為可訪問。 * 使用以下方法修改設置參數: * 1、setAllowUserInteraction * 2、setDoInput * 3、setDoOutput * 4、setIfModifiedSince * 5、setUseCaches * 使用以下方法修改一般屬性: * setRequestProperty * 使用setDefaultAllowUserInteraction和setDefaultUseCache可設置AllowUserInteraction和UseCache參數的默認值 * 上面每個set方法都有一個用於獲取參數值或一般請求屬性值的對應get方法。適用的具體參數和一般請求屬性取決於協議。 * 在建立到遠程對象的連接之后,以下方法用於訪問頭字段和內容: * getContent * getHeaderField * getInputStream * getOutputStream * 一些頭字段需要經常訪問。以下方法: * getContentEncoding * getContentLength * getContentType * getDate * getExpiraction * getLastModifed * 提供這些對象的便捷訪問。getContent方法適用getContentType方法以確定遠程對象類型。子類重寫getContentType方法很容易 * 一般情況下,所有的預連接參數和一般請求屬性都可忽略:預連接參數和一般請求屬性默認為敏感詞。對於此接口的大多數客戶端而言,只有兩個需要的方法:getInputStream和getContent,它們通過便捷方法鏡像到URL類中。 * 有關fileNameMap的注意事項:在JDK1.6以前的版本中,URLConnection的fileNameMap字段是公共的。在JDK1.1.6以及后面的版本中,fileNameMap字段是私有的;對其添加了accessor方法和mutaor方法getFieldNameMap以及 * setFieldNameMap以便訪問。完成請求后,在一個URLConnection的InputStream或OutputStream上調用close()方法可以釋放與此實例相關的網絡資源,除非特定的協議規范為其制定了其他行為。 字段: protected boolean allowUserInteraction 如果為 true,則在允許用戶交互(例如彈出一個驗證對話框)的上下文中對此 URL 進行檢查。 protected boolean connected 如果為 false,則此連接對象尚未創建到指定 URL 的通信鏈接。 protected boolean doInput 此變量由 setDoInput 方法設置。 protected boolean doOutput 此變量由 setDoOutput 方法設置。 protected long ifModifiedSince 有些協議支持跳過對象獲取,除非該對象在某個特定時間點之后又進行了修改。 protected URL url URL 表示此連接要在互聯網上打開的遠程對象。 protected boolean useCaches 如果為 true,則只要有條件就允許協議使用緩存。 構造: protected URLConnection(URL url) 構造一個到指定 URL 的 URL 連接。 方法: void addRequestProperty(String key, String value) 添加由鍵值對指定的一般請求屬性。 abstract void connect() 打開到此 URL 引用的資源的通信鏈接(如果尚未建立這樣的連接)。 boolean getAllowUserInteraction() 返回此對象的 allowUserInteraction 字段的值。 int getConnectTimeout() 返回連接超時設置。 Object getContent() 獲取此 URL 連接的內容。 Object getContent(Class[] classes) 獲取此 URL 連接的內容。 String getContentEncoding() 返回 content-encoding 頭字段的值。 int getContentLength() 返回 content-length 頭字段的值。 String getContentType() 返回 content-type 頭字段的值。 long getDate() 返回 date 頭字段的值。 static boolean getDefaultAllowUserInteraction() 返回 allowUserInteraction 字段的默認值。 static String getDefaultRequestProperty(String key) 已過時。 應在獲得 URLConnection 的適當實例后使用特定 getRequestProperty 方法的實例。 boolean getDefaultUseCaches() 返回 URLConnection 的 useCaches 標志的默認值。 boolean getDoInput() 返回此 URLConnection 的 doInput 標志的值。 boolean getDoOutput() 返回此 URLConnection 的 doOutput 標志的值。 long getExpiration() 返回 expires 頭字段的值。 static FileNameMap getFileNameMap() 從數據文件加載文件名映射(一個 mimetable)。 String getHeaderField(int n) 返回第 n 個頭字段的值。 String getHeaderField(String name) 返回指定的頭字段的值。 long getHeaderFieldDate(String name, long Default) 返回解析為日期的指定字段的值。 int getHeaderFieldInt(String name, int Default) 返回解析為數字的指定字段的值。 String getHeaderFieldKey(int n) 返回第 n 個頭字段的鍵。 Map<String,List<String>> getHeaderFields() 返回頭字段的不可修改的 Map。 long getIfModifiedSince() 返回此對象的 ifModifiedSince 字段的值。 InputStream getInputStream() 返回從此打開的連接讀取的輸入流。 long getLastModified() 返回 last-modified 頭字段的值。 OutputStream getOutputStream() 返回寫入到此連接的輸出流。 Permission getPermission() 返回一個權限對象,其代表建立此對象表示的連接所需的權限。 int getReadTimeout() 返回讀入超時設置。 Map<String,List<String>> getRequestProperties() 返回一個由此連接的一般請求屬性構成的不可修改的 Map。 String getRequestProperty(String key) 返回此連接指定的一般請求屬性值。 URL getURL() 返回此 URLConnection 的 URL 字段的值。 boolean getUseCaches() 返回此 URLConnection 的 useCaches 字段的值。 static String guessContentTypeFromName(String fname) 根據 URL 的指定 "file" 部分嘗試確定對象的內容類型。 static String guessContentTypeFromStream(InputStream is) 根據輸入流的開始字符嘗試確定輸入流的類型。 void setAllowUserInteraction(boolean allowuserinteraction) 設置此 URLConnection 的 allowUserInteraction 字段的值。 void setConnectTimeout(int timeout) 設置一個指定的超時值(以毫秒為單位),該值將在打開到此 URLConnection 引用的資源的通信鏈接時使用。 static void setContentHandlerFactory(ContentHandlerFactory fac) 設置應用程序的 ContentHandlerFactory。 static void setDefaultAllowUserInteraction(boolean defaultallowuserinteraction) 將未來的所有 URLConnection 對象的 allowUserInteraction 字段的默認值設置為指定的值。 static void setDefaultRequestProperty(String key, String value) 已過時。 應在獲得 URLConnection 的適當實例后使用特定 setRequestProperty 方法的實例。調用此方法沒有任何作用。 void setDefaultUseCaches(boolean defaultusecaches) 將 useCaches 字段的默認值設置為指定的值。 void setDoInput(boolean doinput) 將此 URLConnection 的 doInput 字段的值設置為指定的值。 void setDoOutput(boolean dooutput) 將此 URLConnection 的 doOutput 字段的值設置為指定的值。 static void setFileNameMap(FileNameMap map) 設置 FileNameMap。 void setIfModifiedSince(long ifmodifiedsince) 將此 URLConnection 的 ifModifiedSince 字段的值設置為指定的值。 void setReadTimeout(int timeout) 將讀超時設置為指定的超時值,以毫秒為單位。 void setRequestProperty(String key, String value) 設置一般請求屬性。 void setUseCaches(boolean usecaches) 將此 URLConnection 的 useCaches 字段的值設置為指定的值。 String toString() 返回此 URL 連接的 String 表示形式。 */ public class URLConnectionTest { }
ok,現在開始學習使用發送請求了,這個我主要是敲了一遍這位大哥的代碼:
http://www.cnblogs.com/nick-huang/p/3859353.html
代碼貼出來:

package com.http; import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; /** * Created by zhen on 2017-06-26. */ public class TestHttp { public static void main(String[] args){ String result = null; try { // result = doGet(); result = doPost(); } catch (Exception e) { e.printStackTrace(); } System.out.println(result); } public static String doGet() throws Exception{ URL localUrl = new URL("http://localhost:8080/"); URLConnection connection = localUrl.openConnection(); HttpURLConnection httpURLConnection = (HttpURLConnection) connection; httpURLConnection.setRequestProperty("Accept-Charset", "UTF-8"); httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); InputStream inputStream = null; InputStreamReader inputStreamReader = null; BufferedReader reader = null; StringBuffer resultBuffer = new StringBuffer(); String tempLine = null; if(httpURLConnection.getResponseCode() >=300){ throw new Exception("HTTP Request is not success, Response code is " + httpURLConnection.getResponseCode()); } try{ inputStream = httpURLConnection.getInputStream(); inputStreamReader = new InputStreamReader(inputStream); reader = new BufferedReader(inputStreamReader); while((tempLine = reader.readLine()) != null){ resultBuffer.append(tempLine); } }finally { if(reader != null){ reader.close(); } if(inputStreamReader != null){ inputStreamReader.close(); } if(inputStream != null){ inputStream.close(); } } return resultBuffer.toString(); } public static String doPost() throws Exception{ String parameterData = "username=nicekuangg&blog=http://www.cnblogs.com/nick-kuang/"; URL localUrl = new URL("http://localhost:8080/loginServlet"); URLConnection connection = localUrl.openConnection(); HttpURLConnection httpURLConnection = (HttpURLConnection) connection; httpURLConnection.setDoOutput(true); httpURLConnection.setRequestMethod("POST"); httpURLConnection.setRequestProperty("Accept-Charset", "UTF-8"); httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); httpURLConnection.setRequestProperty("Content-Length", String.valueOf(parameterData.length())); OutputStream outputStream = null; OutputStreamWriter outputStreamWriter = null; InputStream inputStream = null; InputStreamReader inputStreamReader = null; BufferedReader reader = null; StringBuffer resultBuffer = new StringBuffer(); String tempLine = null; try{ outputStream = httpURLConnection.getOutputStream(); outputStreamWriter = new OutputStreamWriter(outputStream); outputStreamWriter.write(parameterData.toString()); outputStreamWriter.flush(); if(httpURLConnection.getResponseCode() >=300){ throw new Exception("HTTP Response is not sucess, Response code is " + httpURLConnection.getResponseCode()); } inputStream = httpURLConnection.getInputStream(); inputStreamReader = new InputStreamReader(inputStream); reader = new BufferedReader(inputStreamReader); while((tempLine = reader.readLine()) != null){ resultBuffer.append(tempLine); } }finally{ if(outputStreamWriter != null){ outputStreamWriter.close(); } if(outputStream != null){ outputStream.close(); } if(reader != null){ reader .close(); } if(inputStreamReader != null){ inputStreamReader.close(); } if(inputStream != null){ inputStream.close(); } } return resultBuffer.toString(); } }

package com.http; import java.io.*; import java.net.*; import java.util.Map; /** * Created by zhen on 2017-06-26. */ public class HttpRequestor { private String charset = "UTF-8"; private Integer connectionTimeout = null; private Integer socketTimeout = null; private String proxyHost = null; private Integer proxyPort = null; public String doGet(String url) throws Exception{ URL localUrl = new URL(url); URLConnection connection = openConnection(localUrl); HttpURLConnection httpURLConnection = (HttpURLConnection) connection; httpURLConnection.setRequestProperty("Accept-Charset", charset); httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); InputStream inputStream = null; InputStreamReader inputStreamReader = null; BufferedReader reader = null; StringBuffer resultBuffer = new StringBuffer(); String tempLine = null; if(httpURLConnection.getResponseCode() >= 300){ throw new Exception("HTTP Request is not success, Response code is " + httpURLConnection.getResponseCode()); } try{ inputStream = httpURLConnection.getInputStream(); inputStreamReader = new InputStreamReader(inputStream); reader = new BufferedReader(inputStreamReader); while((tempLine = reader.readLine()) != null){ resultBuffer.append(tempLine); } }finally{ if(reader != null){ reader.close(); } if(inputStreamReader != null){ inputStreamReader.close(); } if(inputStream != null){ inputStream.close(); } } return resultBuffer.toString(); } public String doPost(String url, Map parameterMap) throws Exception{ StringBuffer parameterData = new StringBuffer(); if(parameterMap != null){ for(Object key : parameterMap.keySet()){ parameterData = parameterData.append(key).append("=").append(parameterMap.get(key)).append("&"); } parameterData = parameterData.deleteCharAt(parameterData.length() - 1); } URL localUrl = new URL(url); URLConnection connection = openConnection(localUrl); HttpURLConnection httpURLConnection = (HttpURLConnection) connection; renderRequest(httpURLConnection); httpURLConnection.setDoOutput(true); httpURLConnection.setRequestMethod("POST"); httpURLConnection.setRequestProperty("Accept-Charset", "UTF-8"); httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); httpURLConnection.setRequestProperty("Content-Length", String.valueOf(parameterData.length())); OutputStream outputStream = null; OutputStreamWriter outputStreamWriter = null; InputStream inputStream = null; InputStreamReader inputStreamReader = null; BufferedReader reader = null; StringBuffer resultBuffer = new StringBuffer(); String tempLine = null; try{ outputStream = httpURLConnection.getOutputStream(); outputStreamWriter = new OutputStreamWriter(outputStream); outputStreamWriter.write(parameterData.toString()); outputStreamWriter.flush(); inputStream = httpURLConnection.getInputStream(); inputStreamReader = new InputStreamReader(inputStream); reader = new BufferedReader(inputStreamReader); while((tempLine = reader.readLine()) != null){ resultBuffer.append(tempLine); } }finally{ if(outputStreamWriter != null){ outputStreamWriter.close(); } if(outputStream != null){ outputStream.close(); } if(reader != null){ reader.close(); } if(inputStreamReader != null){ inputStreamReader.close(); } if(inputStream != null){ inputStream.close(); } } return resultBuffer.toString(); } private URLConnection openConnection(URL localUrl) throws IOException{ URLConnection connection; if(proxyHost != null && proxyPort != null){ Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); connection = localUrl.openConnection(proxy); }else{ connection = localUrl.openConnection(); } return connection; } private void renderRequest(URLConnection connection){ if(connectionTimeout != null){ connection.setConnectTimeout(connectionTimeout); } if(socketTimeout != null){ connection.setReadTimeout(socketTimeout); } } public String getCharset() { return charset; } public void setCharset(String charset) { this.charset = charset; } public Integer getConnectionTimeout() { return connectionTimeout; } public void setConnectionTimeout(Integer connectionTimeout) { this.connectionTimeout = connectionTimeout; } public Integer getSocketTimeout() { return socketTimeout; } public void setSocketTimeout(Integer socketTimeout) { this.socketTimeout = socketTimeout; } public String getProxyHost() { return proxyHost; } public void setProxyHost(String proxyHost) { this.proxyHost = proxyHost; } public Integer getProxyPort() { return proxyPort; } public void setProxyPort(Integer proxyPort) { this.proxyPort = proxyPort; } } package com.http; import java.util.HashMap; import java.util.Map; /** * Created by zhen on 2017-06-26. */ public class HttpRequestorTest { public static void main(String[] args){ HttpRequestor httpRequestor = new HttpRequestor(); String doGetResult = null; String doPostResult = null; Map parameterMap = new HashMap<String, String>(); parameterMap.put("username", "nicekuang"); parameterMap.put("blog", "http://www.cnblogs.com/nice-kuang/"); try { doGetResult = httpRequestor.doGet("http://localhost:8080/loginServlet"); doPostResult = httpRequestor.doPost("http://localhost:8080/loginServlet", parameterMap); } catch (Exception e) { e.printStackTrace(); } System.out.println(doGetResult); System.out.println(doPostResult); } }