程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> j2ee-J2EE做的網站,要訪問其他網站

j2ee-J2EE做的網站,要訪問其他網站

編輯:編程綜合問答
J2EE做的網站,要訪問其他網站

就出現以下異常:
javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name
at sun.security.ssl.ClientHandshaker.handshakeAlert(ClientHandshaker.java:1292)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1952)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1077)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.mymap.model.CaptureJavascript.getPosition(CaptureJavascript.java:60)

嘗試照網上說的添加: **System.setProperty("jsse.enableSNIExtension", "false");**
但是無效。

以下是我的代碼。該方法在Capture類中,servlet類中調用Capture類的方法,方法代碼如下:
private double[] getPosition(double lat, double lon) throws Exception
{

    System.setProperty("jsse.enableSNIExtension", "false");
    String strURL = "https://eosweb.larc.nasa.gov/cgi-bin/sse/grid.cgi?&num=230000&lat=" + lat + 
            "&submit=Submit&veg=17&p=swv_dwn&step=2&lon=" + lon;
    //"https://eosweb.larc.nasa.gov/cgi-bin/sse/grid.cgi?&num=199997&lat=" + lat + "&submit=Submit&veg=17&p=swv_dwn&step=2&lon=" + lon;

    URL url = new URL(strURL);
    HttpURLConnection httpConn =  (HttpURLConnection) url.openConnection();

    InputStreamReader input = new InputStreamReader(httpConn.getInputStream(), "utf-8");
    BufferedReader bufReader = new BufferedReader(input);
    StringBuilder contentBuf = new StringBuilder();
    String line = "";
    while((line = bufReader.readLine()) != null) {
        contentBuf.append(line);
    }

    String buf = contentBuf.toString();
    int beginIx = buf.indexOf("year Average");
    int endIx = buf.indexOf("Minimum And Maximum Difference");
    String resultstr = buf.substring(beginIx, endIx);

    return getDoubles(resultstr);
}

最佳回答:


http://demo.netfoucs.com/will_awoke/article/details/38587467
看樓主看一下把,不知道能解決你的問題不能

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved