Https connection

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

    #1

    Https connection

    hello everyone!!!
    Heres a code to open a link to an https site and read its contents...
    but it gives an exception...Cla ssCastException
    [code=c]
    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();
    [/code]
    can someone help me out as to what should i do...where defaultURL is the URL i want to see the contents of...pls help me out.....
Working...