我可以使用我的java类成功连接到我的网站。
URLConnection myURLConnection=null; URL myURL=null; BufferedReader reader=null;
String mainUrl="https://example.com/ServCon/ServConI?";
StringBuilder sbPostData= new StringBuilder(mainUrl);
sbPostData.append("page=").append(mpage);
mainUrl = sbPostData.toString();
try {
//prepare connection
myURL = new URL(mainUrl);
myURLConnection = myURL.openConnection();
myURLConnection.connect();
reader= new BufferedReader(new
InputStreamReader(myURLConnection.getInputStream(),"UTF-8"));
} catch(Exception e) {
System.out.println(e);
}
但问题是,当我尝试使用相同的java类从jsp文件连接时,我会收到错误:
e = (SSLHandshakeException) javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid
certification path to requested target
我使用的是Glassfish 5.1.0 jdk 1.8.0_301和apache netbeans 12.5
1条答案
按热度按时间fumotvh31#
好吧!我已经挣扎了几天。终于我可以解决这个问题。问题是Glassfish服务器。我用Tomcat 9服务器替换。但是它也不想工作。然后最后我意识到Tomcat 9服务器需要停止,因为NetBeans在执行基于web的项目(如jsp / servlet)时启动它。它工作得很好。谢谢