File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes HTTPS Post Request through the URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HTTPS Post Request through the URL" Watch "HTTPS Post Request through the URL" New topic

HTTPS Post Request through the URL

Amitabh Sinha

Joined: Sep 02, 2004
Posts: 1
Hi Guys

When I try sending the https post request through the java program

String param = "";
URL url = new URL(param);
HttpsURLConnection httpConnection =
jrunCookie = httpConnection.getHeaderField("set-cookie");
httpConnection.setRequestProperty("referer", param);

it throws the exception and exception reads as URL is not correct. it should be

Could sanyone help me with the code forthis perpose.
Pat Hays
Ranch Hand

Joined: Aug 20, 2004
Posts: 138
have a look the following code, it may be helpful for you.
Sending a POST Request Using a Socket.

try {
// Construct data
String data = URLEncoder.encode("key1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");
data += "&" + URLEncoder.encode("key2", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");

// Send data
URL url = new URL("http://hostname:80/cgi");
URLConnection conn = url.openConnection();
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());

// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
// Process line...
} catch (Exception e) {

Download Java GUI Builder, <a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: HTTPS Post Request through the URL
Similar Threads
https post request issue
HttpsURLConnection problem
How to attach a certificate to a socket and send a https POST request?
Working with HttpsURLConnection
Posting values to HTTPS Url