简体   繁体   中英

How to resolve SSLHandshake fail exception error using jsp

I could successfully connect to my website using my java class.

URLConnection myURLConnection=null; URL myURL=null; BufferedReader reader=null;

String mainUrl="https://eximon.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); 
}

But the problem is when I am trying to connect from jsp file using same java class then I am getting error:

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

I am using Glassfish 5.1.0 jdk 1.8.0_301 and apache Netbeans 12.5

Well! I have have been struggling for last few days. Finally I could resolve the issue. The problem was Glassfish server. I replaced with Tomcat 9 server. But it want not working with that also. Then finally I realized that Tomcat 9 server need to be stop because NetBeans start at it on while executive web based project like jsp / servlet. It worked fine. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM