Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Trying to connect to an https://domain.com URL via Java and failingto do so

Reply
Thread Tools

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

 
 
Rob
Guest
Posts: n/a
 
      05-07-2012
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?

 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      05-07-2012
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.


 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      05-07-2012
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


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      05-08-2012
On Mon, 7 May 2012 13:28:01 -0700 (PDT), Rob <> 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.
..
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird set up - trying to connect via ad hoc Jaded Sapphire Wireless Networking 0 10-10-2008 04:35 PM
connect a database in remote server (can connect to the server via SSH) zhangxiaoyu912@gmail.com Perl Misc 2 07-18-2007 07:20 PM
Aliant TV - Trying to connect a wireless router, not able to connect to Internet rich irving Computer Support 5 01-11-2006 06:30 PM
URL - substitution of a correct URL by a GUID like URL in favorites. Just D. ASP .Net Mobile 0 08-11-2004 04:26 PM
redirect URL's, return URL's, and URL Parameters Jon paugh ASP .Net 1 07-10-2004 05:29 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57