This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 8836
    
    7

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class Cast Exception in HttpURLConnection
 
Similar Threads
How to make a 'post' request from an application to a Servlet
Hit A Servlet From an Applet with values in the URL for the Servlet
URLConnection throws EOFException
SSO connection issue
Connection timed out when server is present in a far off place