Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

How to do http POST with JAVA?

Thread view: 
rodrigo.rodenbeek@gmail.com - 12 Apr 2006 04:41 GMT
Hello, guys.

I would like to knoe how to do following example in java, instead of
PHP

--- start ---
$id = 1;
$postUrlData = array(  'id' => $id );

$ch = curl_init();

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_URL, "http://mysite/some-cgi" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postUrlData );

$data_returned = curl_exec( $ch );
curl_close( $ch );

if( $data_returned == "ok" )
  echo "<pre>it's ok</pre>";
--- end ---

Regards,
Rodrigo
Alex Hunsley - 12 Apr 2006 09:05 GMT
> Hello, guys.
>
> I would like to knoe how to do following example in java, instead of
> PHP

Google is your friend.
Personally, I find Jakarta's HttpClient likeable and it doesn't soil the
carpet.

http://jakarta.apache.org/commons/httpclient/

Check out the tutorials for HttpClient at the above page, they include
doing GET or POST requests.
Thomas Fritsch - 12 Apr 2006 14:26 GMT
> I would like to knoe how to do following example in java, instead of
> PHP
[quoted text clipped - 16 lines]
>    echo "<pre>it's ok</pre>";
> --- end ---

You can use URL and URLConnection as described in
http://javaalmanac.com/egs/java.net/Post.html

Signature

"Thomas:Fritsch$ops.de".replace(':', '.').replace('$', '@')



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.