Trying to connect to an https://domain.com URL via Java and failingto do so

R

Rob

Can anyone help me understand why this is not working:

Here is the important part. When compiled and run:
String Urlx="https://domain.com" // valid URL that comes up fine in a
web browser
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
URL url = new URL(Urlx);
in = url.openStream(); // Currently An IoException is thrown
:

It appears an IoException is thrown: java.io.IOException: Server
returned HTTP response code: 403 for URL: https://domain.com

Does anyone know why this might be happening and what if anything is
missing? e.g missing .jar file? A different way to accomplish this in
Java JDK?
 
D

Daniel Pitts

Can anyone help me understand why this is not working:

Here is the important part. When compiled and run:
String Urlx="https://domain.com" // valid URL that comes up fine in a
web browser
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
URL url = new URL(Urlx);
in = url.openStream(); // Currently An IoException is thrown
:

It appears an IoException is thrown: java.io.IOException: Server
returned HTTP response code: 403 for URL: https://domain.com

Does anyone know why this might be happening and what if anything is
missing? e.g missing .jar file? A different way to accomplish this in
Java JDK?

http://lmgtfy.com/?q=http+403

It means the server doesn't like something about your request. Many
websites don't allow Java's default User-Agent, for many reasons.
Likely you are (perhaps unintentionally) violating the ToS of the site
you're attempting to connect to.
 
A

Arne Vajhøj

Can anyone help me understand why this is not working:

Here is the important part. When compiled and run:
String Urlx="https://domain.com" // valid URL that comes up fine in a
web browser
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
URL url = new URL(Urlx);
in = url.openStream(); // Currently An IoException is thrown
:

It appears an IoException is thrown: java.io.IOException: Server
returned HTTP response code: 403 for URL: https://domain.com

Does anyone know why this might be happening and what if anything is
missing? e.g missing .jar file? A different way to accomplish this in
Java JDK?

I don't think you need to specify any properties to use HTTPS in
any recent Java.

Whether that makes a difference or not I don't know.

Arne
 
R

Roedy Green

String Urlx="https://domain.com" // valid URL that comes up fine in a
web browser
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
URL url = new URL(Urlx);
in = url.openStream(); // Currently An IoException is thrown

See http://mindprod.com/products1.html#HTTP

You get use the GET class to fetch either http: or https:
Java selects the https: handler transparently.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML.
They forget that the simplest language is the one you
already know. They also forget that their simple little
markup language will bit by bit become even more convoluted
and complicated than HTML because of the unplanned way it grows.
..
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top