• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HttpsConnection not establishing?

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

here is the code
----------------------------------------------------------------------------
try {

HttpsConnection con= (HttpsConnection) Connector.open("http://www.yahoo.com");

DataInputStream di = con.openDataInputStream();

SecurityInfo si= con.getSecurityInfo();

System.out.println(si.getCipherSuite() +" "+ si.getProtocolName()+ " "+ si.getProtocolVersion());

byte[] arr=new byte[(int)con.getLength()];

{
c=di.readChar();
di.readFully(arr);
System.out.print(new String(arr));
}
con.close();

}catch(Exception e) {}
----------------------------------------------------------------------------

this code is giving me ClassCastException. The code is working fine if i establish plain HttpConnection. I am able to see the yahoo main page scripts. Is it that www.yahoo.com page doesnt support secure connections???
What can be the probable reason?
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you are missing an 's' or ':443' from your URL.

HTTP/S does not appear to be enabled on Yahoo's main page. When attempting a secure connection to Yahoo I am redirected to port 80.

Here is the wget output:




If you are using Yahoo to test your code, I would suggest using https://login.yahoo.com or https://mail.yahoo.com.

The full wget is below:

reply
    Bookmark Topic Watch Topic
  • New Topic