Why the HttpsURLConnection I got is different in two scenarios?->ClassCastE

I got the a problem!

I used a common block code to connect to a https server,but I got ClassCastException

(HttpsURLConnection) URL.openConnection() works well in a standalone application.

but the same code thorws ClassCastException while it run in a servlet thread.

I use toString() to print the Object content which I got from URL.openConnection() and I found a strange but maybe important thing:

the Object I got is different in two scenarios!

Object returned in standalone application is sun.net.www.protocol.https.DelegateHttpsURLConnection

and in servlet thread is

com.sun.net.ssl.internal.www.protocol.https.DelegateHttpsURLConnection

Who can explain this and help me?

I think I can pass this problem while I find the way to get sun.net.www.protocol.https.DelegateHttpsURLConnection in servlet thread

[875 byte] By [wonghta] at [2007-10-1 3:42:05]
# 1
To solve this problem, it must to force JVM load new JSSE ProviderPls use this, it work for me System.setProperty("java.protocol.handler.pkgs","sun.net.www.protocol");
wonghta at 2007-7-8 22:33:36 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2
It sounds like your servlet is forcing the old style com.sun.net.ssl HttpsURLConnection as is documented in JSSE 1.0.x. This will override the default, which points at sun.net.www.protocol, to the old one which was left in for compatibiliity with JSSE 1.0.x.
wetmorea at 2007-7-8 22:33:36 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...