Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Arvind Chari
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,

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

Regards,
Arvind.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic