Creating HTTP and HTTPS connections in Java applications  HTTPS connections

Chapter 5: Using SSL in Java Clients

HTTP connections

The standard Java virtual machine provides HTTP connectivity with these classes in java.net package:

For details on these classes, see the JDK documentation. The following code shows a typical example. This code opens a connection, retrieves the data (text is assumed), and prints it:

URL url = new URL("http://www.sybase.com/");
URLConnection conn = url.openConnection();
conn.connect();
InputStreamReader content 
    = new InputStreamReader(conn.getInputStream());
for (int i=0; i != -1; i = content.read())
{
    System.out.print((char) i);  
} 




Copyright © 2005. Sybase Inc. All rights reserved. HTTPS connections

View this book as PDF