Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #14381 > unrolled thread

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

Started byRob <rss245@gmail.com>
First post2012-05-07 13:28 -0700
Last post2012-05-07 20:09 -0700
Articles 4 — 4 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Trying to connect to an https://domain.com  URL via Java and failing to do so Rob <rss245@gmail.com> - 2012-05-07 13:28 -0700
    Re: Trying to connect to an https://domain.com  URL via Java and failing to do so Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-07 14:06 -0700
    Re: Trying to connect to an https://domain.com  URL via Java and failing to do so Arne Vajhøj <arne@vajhoej.dk> - 2012-05-07 18:12 -0400
    Re: Trying to connect to an https://domain.com  URL via Java and failing to do so Roedy Green <see_website@mindprod.com.invalid> - 2012-05-07 20:09 -0700

#14381 — Trying to connect to an https://domain.com URL via Java and failing to do so

FromRob <rss245@gmail.com>
Date2012-05-07 13:28 -0700
SubjectTrying to connect to an https://domain.com URL via Java and failing to do so
Message-ID<cc72f82a-3e1a-449b-840c-8af89e3de388@v2g2000vbx.googlegroups.com>
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?

[toc] | [next] | [standalone]


#14382

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2012-05-07 14:06 -0700
Message-ID<iPWpr.2510$MY4.1021@newsfe14.iad>
In reply to#14381
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.

[toc] | [prev] | [next] | [standalone]


#14384

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-05-07 18:12 -0400
Message-ID<4fa848b6$0$289$14726298@news.sunsite.dk>
In reply to#14381
On 5/7/2012 4: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?

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

[toc] | [prev] | [next] | [standalone]


#14385

FromRoedy Green <see_website@mindprod.com.invalid>
Date2012-05-07 20:09 -0700
Message-ID<qh3hq7pb1o5329klo5llnftllq7bh6gkt5@4ax.com>
In reply to#14381
On Mon, 7 May 2012 13:28:01 -0700 (PDT), Rob <rss245@gmail.com> wrote,
quoted or indirectly quoted someone who said :

>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.
.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web