• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

HttpURLConection and ClassCastException

Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written an applet in which i am trying to connect to a server using

URL u = new URL("http://www.google.com/";);
HttpURLConnection uc = (HttpURLConnection) u.openConnection();

The code throws java.lang.ClassCastException: com/ms/net/wininet/http/HttpURLConnection
at run time. The reason i found is that different browser and their versions do not to return the same java.net.HttpURLConnection on URL.openConnection. e.g. in case of IE it returns com.ms.net.wininet.http.HttpURLConnection.

Since the applet code will run on different browser with different version. Is there a way around to solve this issue. :roll:
Also how to check for the connection with a specific remote server if the client browser setting is through proxy??
Thankyou for ur interest and time
Best Regards
Posts: 9099
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this instead ...

URL u = new URL("http://www.google.com/";);
URLConnection con = u.openConnection();
There is no "i" in denial. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic