2015-06-22 93 views
0

蔭使用下面的代碼通過現在下面的代碼部署在Linux(SFTP)服務器爲Apache Tomcat作爲sms.jsp頁面賣方輪不到服務器響應

URL url = new URL("http://example.com"); 
URLConnection conn = url.openConnection(); 
for (int i = 0;; i++) { 
    String headerName = conn.getHeaderFieldKey(i); 
    String headerValue = conn.getHeaderField(i); 
    System.out.println(headerName + "==="); 
    System.out.println(headerValue); 
    if (headerName == null && headerValue == null) { 
    break; 
    } 
} 

發送短信給我的客戶。此sms.jsp頁面通過另一個頁面名稱trysms.asp調用,並且SMS已成功發送。供應商服務器提供該消息發送或失敗的響應。但是,當我從trysms.asp頁面調用這些sms.jsp時,SMS被髮送到手機號碼,但是我未能從供應商服務器得到msg在我的瀏覽器中發送或失敗的響應。如何根據我必須維護我的數據庫。

回答

0

我用下面的代碼從供應商的服務器響應

<% 
    URL url = new URL("..."); 
    HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 
    connection.setRequestMethod("GET"); 
    connection.connect(); 
    reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); 
    String line=reader.readLine(); 
    while(line!=null) 
    { 
     out.println(line); 
     line=reader.readLine(); 
    } 
    %> 

罪魁禍首是System.out.println這不被打印在瀏覽器中的任何行。當我排除System.然後它打印。 使用HttpURLConnection使問題得以解決