2015-06-22 49 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使问题得以解决