Article ID: 191120
Article Last Modified on 7/14/2004
java.net.URL.setURLStreamHandlerFactory(
new com.ms.net.wininet.WininetStreamHandlerFactory());
import java.net.*;
import java.io.*;
public class HTTPS
{
public static void main(String args[]) {
/*
Install a URLStreamHandler that can handle the HTTPS: protocol.
*/
try {
if (Class.forName(
"com.ms.net.wininet.WininetStreamHandlerFactory" )!=null)
URL.setURLStreamHandlerFactory(new
com.ms.net.wininet.WininetStreamHandlerFactory());
} catch (ClassNotFoundException ex) {
System.err.println(
"Warning: WininetStreamHandlerFactory class not found.");
}
try {
/*
The following line assumes that you have a HTTPS: server on your
local machine, with a Login.ASP page in the root directory. You
can replace the following line with any valid HTTPS: URL.
*/
String page="https://localhost/Login.asp";
URL url=new URL(page);
URLConnection connection=url.openConnection();
connection.setAllowUserInteraction(true);
DataInputStream dis=new DataInputStream(
connection.getInputStream());
String input;
do {
input=dis.readLine();
if (input!=null)
System.out.println(input);
} while (input!=null);
dis.close();
} catch (IOException ex) {
System.err.println("IOException, make sure the URL is valid.");
ex.printStackTrace();
}
}
}
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Derek
Jamison, Microsoft Corporation
Keywords: kbnetwork kbjava kbprb KB191120