Https connection???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rushnitrkl22
    New Member
    • May 2007
    • 10

    Https connection???

    hi everyone!!!
    Heres a code to link to an Https site and read the contents of it.But i get an ClassCastExcept ion...Pls help me out as to whyI m getting this error and ..how can it be rectified....
    URL aURL;
    char ch;
    Security.addPro vider(new com.sun.net.ssl .internal.ssl.P rovider());
    System.setPrope rty("java.proto col.handler.pkg s","com.sun.net .ssl.internal.w ww.protocol");

    aURL = new URL(null,defaul tURL, new com.sun.net.ssl .internal.www.p rotocol.https.H andler());
    HttpsURLConnect ion urlConn = (HttpsURLConnec tion)aURL.openC onnection();


    System.out.prin tln("before URL");
    System.out.prin tln("after new URL");

    System.out.prin tln("after openconnction") ;
    BufferedReader in = new BufferedReader( new InputStreamRead er(urlConn.open Stream()));

    String inputLine;

    while ((inputLine = in.readLine()) != null)
    System.out.prin tln(inputLine);

    in.close();
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    You're not supposed to use the classes in package(s) com.sun.* there must be
    an equivalent class in the public API.

    kind regards,

    Jos

    Comment

    • rushnitrkl22
      New Member
      • May 2007
      • 10

      #3
      Originally posted by JosAH
      You're not supposed to use the classes in package(s) com.sun.* there must be
      an equivalent class in the public API.

      kind regards,

      Jos
      thanks for ur reply!!!!
      which class in the API should I use???

      Comment

      Working...