This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Using Get/Post with HTTPS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Using Get/Post with HTTPS" Watch "Using Get/Post with HTTPS" New topic

Using Get/Post with HTTPS

Kondal Rao

Joined: Apr 05, 2000
Posts: 18
I am playing with Tony Alicea's Application to get the HTTP header. It is a well written application. Good job...Tony
I have the following requirements. We have been using a proxy server. So I should be able to specify the IP address of the proxy server. I need to Get/Post some data from/to a web site which is using HTTPS protocol.
I read somewhere We have to use URLConnection class rather than HttpURLConnection for doing this. Has anybody done this? i.e. writing a Client java application to Get/Post data to HTTPS server?
I really apprecaite, if anyone can through some light on this.
Tony Alicea

Joined: Jan 30, 2000
Posts: 3222
Well, thanks... my employer also likes that app... And since I am now (well, was, since they made an exception and now allow my workstation to BYPASS the proxy...)
From the Java FAQ at (Peter van der Linden's):

10.(Sect. 15) How do I get a URLConnection to work through proxy firewalls? I.e. How do you get your
application to do its web accesses through a proxy?
This is typically needed for any net access to another domain. Tell the run time system what you are trying to do, by using these commandline arguments when you start the program.
java -DproxySet=true -DproxyHost=SOMEHOST -DproxyPort=SOMENUM classname
Note proxyPort is optional and it defaults to 80. Without this, you will see an exception like or
The proxy settings work for, but apparently not for Update! The proxyHost and proxyPort systems properties (from 1.0.2) are deprecated, you should use http.proxyHost and http.proxyPort. They are for HTTP proxies only. If you are using you are not using the URL classes, and cannot get the proxy behavior.
Netscape's and IE's JVMs (at least in versions 4.x+) take the proxy settings for applets from the browser's proxy configuration. You can also do URL proxies in applications (not applets) with the following code:

// set up to use proxy
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", "");
System.getProperties().put("proxyPort", "80");

Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Kevin Baker

Joined: Jun 20, 2002
Posts: 10
Well, I'm trying to piggy back off this posting. One question, how do you get the proxy settings from the browser's proxy configuration? I know that NS stores them in a flat file but IE stores these setting in the registry and Java doesn't have the capability to read the registry with out using JNI.
Sean Sullivan
Ranch Hand

Joined: Sep 09, 2001
Posts: 427
GeeCON Prague 2014
subject: Using Get/Post with HTTPS