What's the problem of this program

T

tester

Hello, I am writing a java application to get a file from a HTTPS web
server.
The code is shown below. I have installed JSSE in advance (btw, is there
any
way to check whether the JSSE is installed successfully or not?). But I
got
ConnectException:Connection timed out error. Do u have any idea of the
reason?

import java.io.*;
import java.net.*;
import java.security.*;

public class TEST
{
public static void main (String args[]) throws Exception
{
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", "PROXYSERVER");
System.getProperties().put("proxyPort", "8000");
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.w
ww.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
URL url = new URL("https://XXX.com/YYY.txt");
BufferedReader br = new BufferedReader(new
InputStreamReader(url.openStream()));

String line;
while ((line = br.readLine()) != null)
{
System.out.println(line);
}
br.close();
}
}
 
J

John C. Bollinger

tester said:
Hello, I am writing a java application to get a file from a HTTPS web
server.
The code is shown below. I have installed JSSE in advance (btw, is there
any
way to check whether the JSSE is installed successfully or not?). But I
got
ConnectException:Connection timed out error. Do u have any idea of the
reason?

import java.io.*;
import java.net.*;
import java.security.*;

public class TEST
{
public static void main (String args[]) throws Exception
{
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", "PROXYSERVER");
System.getProperties().put("proxyPort", "8000");
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.w
ww.protocol");

Well, for one thing, you can't set system properties that way. It does
nothing. You can set them on the java command line, or (IIRC) in the
appropriate configuration file.


John Bollinger
(e-mail address removed)
 
J

Joe Pribele

tester said:
Hello, I am writing a java application to get a file from a HTTPS web
server.
The code is shown below. I have installed JSSE in advance (btw, is there
any
way to check whether the JSSE is installed successfully or not?). But I
got
ConnectException:Connection timed out error. Do u have any idea of the
reason?

import java.io.*;
import java.net.*;
import java.security.*;

public class TEST
{
public static void main (String args[]) throws Exception
{
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", "PROXYSERVER");
System.getProperties().put("proxyPort", "8000");
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.w
ww.protocol");

Well, for one thing, you can't set system properties that way. It does
nothing. You can set them on the java command line, or (IIRC) in the
appropriate configuration file.


John Bollinger
(e-mail address removed)
Thats not true. to set a proxy server I do this all the time it works
fine.
 
J

John C. Bollinger

Joe said:
tester wrote:
[...]
Well, for one thing, you can't set system properties that way. It does
nothing. You can set them on the java command line, or (IIRC) in the
appropriate configuration file.
[...]

Thats not true. to set a proxy server I do this all the time it works
fine.

Well blow me down. Okay, I checked and you're right, with the caveat
that a security manager can prevent the retrieval of the Properties
object. I don't know what I was thinking.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,206
Latest member
SybilSchil

Latest Threads

Top