Performing HTTP POST in JAVA

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Performing HTTP POST in JAVA

Post by vivekn on Sat Aug 16, 2008 9:46 am
([msg=9849]see Performing HTTP POST in JAVA[/msg])

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
Most things are easier done than said!
vivekn
New User
New User
 
Posts: 18
Joined: Wed Apr 16, 2008 5:02 am
Blog: View Blog (0)


Re: Performing HTTP POST in JAVA

Post by nathandelane on Mon Aug 18, 2008 7:36 am
([msg=9961]see Re: Performing HTTP POST in JAVA[/msg])

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();
...
Me, Nathandelane, Highly influential to Hackerdom, Premature Optimization=http://c2.com/cgi/wiki?PrematureOptimization
User avatar
nathandelane
Poster
Poster
 
Posts: 204
Joined: Thu Jun 26, 2008 11:26 am
Location: Utah
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests