Thx for the suggestion Michael. I think you're on the right track.
I figured out that the reason that I'm getting the ClassCastException is that even though I have:
URL aURL = new URL("https://my.machine.com/xml/xps.cgi");
My:
aURL.openConnection()
is returning a HttpURLConnection, and the cast to HttpsURLConnection is causing the prob.
The confusing thing is this: Does that mean that even though HttpsURLConnection extends HttpURLConnection, it doesn't qualify as a valid return type for URL.openConnection() because it's in the javax.net.ssl package, which does
not belong "to one of the following packages or one of their subpackages: java.lang, java.io, java.util, java.net"?
If so, then what alternative do I have to pass a https URL to URL, and get back a secure, HttpsURLConnection?
I tried the following
test:
URL aURL = new URL("https://www.verisign.com");
URLConnection urlConn = aURL.openConnection();
if (urlConn instanceof com.sun.net.ssl.HttpsURLConnection) {
System.out.println("*** openConnection returns an instanceof com.sun.net.ssl.HttpsURLConnection");
}
if (urlConn instanceof javax.net.ssl.HttpsURLConnection) {
System.out.println("*** openConnection returns an instanceof javax.net.ssl.HttpsURLConnection");
}
if (urlConn instanceof HttpURLConnection) {
System.out.println("*** openConnection returns an instnace of HttpURLConnection");
}
And my output is:
*** openConnection returns an instanceof com.sun.net.ssl.HttpsURLConnection
*** openConnection returns an instnace of HttpURLConnection
Doesn't that seem like a mistake? Why is URL.openConnection() returning a deprecated class?
Furthermore, what do I need to do to get a HttpsURLConnection?
[ February 28, 2003: Message edited by: Aurangzeb Agha ]