File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes simple change to code that uses HTTPUrlConnection to make post request to a form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "simple change to code that uses HTTPUrlConnection to make post request to a form" Watch "simple change to code that uses HTTPUrlConnection to make post request to a form" New topic
Author

simple change to code that uses HTTPUrlConnection to make post request to a form

Arvind Chari
Greenhorn

Joined: Jul 26, 2011
Posts: 8
There is a good code sample given at http://code.google.com/appengine/docs/java/urlfetch/usingjavanet.html that gives an example of how to make a post request to post comments on a web page.

The relevant code is given below-


I want to submit a post request to a form that contains some text fields, a drop down list box, as well as a captcha field with text box named "Captcha". While the form action="http://domain.com/submit.php" the captcha field is linked to captcha image that is generated by page "http://domain.com/captcha.php".

I already have all details about the form with me, now I want to make post request to this form by modifying the above code sample... What I am unable to figure out, is how to map the captcha field with the file "captcha.php"? Ideally I want to display the captcha on screen and ask the end user to fill it in... Once user fills it in, this field along with rest of the values can be submitted to the form... I particularly like this way of submission because the response to submission will also be available to the program directly...Is it possible to submit data to such a form? How do I do this. For now you can take for example total 3 fields in the form "UserID" (Text) "Password" (Text) and "Captcha". How do I treat the captcha value, show it and then submit it? If the captcha is shown on screen, then wont this be a unique value only for that occurence of form? And we are trying to directly submit to form by encoding various parameters, how do we decide on a value for captcha in such a scenario?

Any help/pointers in this regard would be highly appreciated.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
I want to make post request to this form


POST requests are made to servers.

A HTML page may contain a FORM which can generate a POST request.

Are you saying you want to use HTTPUrlConnection to emulate a POST request or what?

Bill
Arvind Chari
Greenhorn

Joined: Jul 26, 2011
Posts: 8
Hi Bill,

Sorry thats my mistake...I want to use HTTPUrlConnection to emulate a POST request

Regards,
Arvind.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: simple change to code that uses HTTPUrlConnection to make post request to a form
 
Similar Threads
fields should be mandatory depending on drop down select
Clearing textbox Sorry post got closed for some reason had to repost
Java Script to clear text box
Duplicate form submission - Synchronizer Token Pattern
Can't use trace, put, delete methods on tomcat