Page 1 of 1

Performing HTTP POST in JAVA

PostPosted: Sat Aug 16, 2008 9:46 am
by vivekn
How do you perform a POST request in java using HttpURLConnection,please give an example

i want to submit form data directly to a script thru java

Thanks in advance

Re: Performing HTTP POST in JAVA

PostPosted: Mon Aug 18, 2008 7:36 am
by nathandelane
http://www.exampledepot.com/egs/java.net/Post.html

The above link shows an example of how to do this in Java. Writing POST data must be done over a stream in Java, which is where this part comes in:

Code: Select all
...
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
...