snajalm
asked on
Constructing a POST HTTPS Request (EMPHASIS ON USERNAME & PASSWORD)
How can I chuck in user credentials (username and password) in an HTTPS POST request in Java??!
ASKER
But how do you setRequestProperty to construct your POST method?!
ASKER
But there is nothing in this link...
They've evidently got problems at that site. Try
http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class
http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class
ASKER
But this link doesn't say anything about how to add "username" and "password" to the POST arguments before sending the request!
Normally you don't do that - authentication is part of the protocol and the responsibility of the Authenticator. If in your case you do, then it would be no different from any other post parameters
ASKER
so would it be something like,
comm.setRequestProperty("u ser", userName);
comm.setRequestProperty("p assword", password);
comm.setRequestProperty("u
comm.setRequestProperty("p
If the server expects them to arrive as headers, then yes
ASKER
Can you please let me know of all the possible ways of constructing a post request? I just want to send the username and password as clear text through POST request!
>>I just want to send the username and password as clear text through POST request!
Well i already posted a link to an example of that. Just change
>>String data = "width=50&height=100";
to
String data = "username=foo&password=bar ";
Well i already posted a link to an example of that. Just change
>>String data = "width=50&height=100";
to
String data = "username=foo&password=bar
ASKER
I found a couple of cool links that help with making an HTTP POST request and make life a whole lot easier.
http://www.java2s.com/Code/Java/Apache-Common/HttppostmethodExample.htm
http://www.devx.com/Java/Article/17679/0/page/1
http://myjavatools.com/
Regards
http://www.java2s.com/Code/Java/Apache-Common/HttppostmethodExample.htm
http://www.devx.com/Java/Article/17679/0/page/1
http://myjavatools.com/
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks heaps for helping through this question!
No problem. As it happens, i'm working on a reusable https server at the moment and it makes stuff like key management quite simple (using Ant)
http://www.exampledepot.com/egs/java.net/Auth.html