aspose file tools*
The moose likes I/O and Streams and the fly likes Class Cast Exception in HttpURLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Class Cast Exception in HttpURLConnection" Watch "Class Cast Exception in HttpURLConnection" New topic
Author

Class Cast Exception in HttpURLConnection

Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
Hi,

I am executing this line this Line works fine on Windows platform and when we move it to AIX Machine this throws a Class Cast Exception.



The URL We are passing is :


mind it it is "Https" Secured URL.

My Question is How is this Code working fine on Windows machine and if It works Why not on IBM - AIX Machine.

Any Comments or Suggestions Appreciated.

Thanks,
Rahul Juneja
rahulj2k3@yahoo.com


Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

You are using different virtual machines, probably from different vendors (the windows VM from Sun and the AIX VM from IBM). This line:

breaks your contract with the API because you are claiming to know something about the implementation of the VM which obviously does not hold between platforms. The API states that openConnection returns an instance of URLConnection. You could test connection with the instanceof operator, but you'd still need to provide some processing for the platforms where connection is not an instance of HttpURLConnection.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
jQuery in Action, 2nd edition
 
subject: Class Cast Exception in HttpURLConnection