This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TextBox and Submit button applet

 
Alan Nalon
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I just would like to write a small applet containing a Text field and a button. When the button is pressed I would like to post the text field like a form would do. The target of this post method is an asp page.
Thanks for your help,
Best Regards,
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The magic of HTTP Tunneling.
When you click on the "submit" button, have an action method that retrieves the text property of the TextField, then get yourself a java.net.HttpURLConnection. Set it up to do a post and place the following items in the POST data stream:
formfieldname\n
textvalue\n
where "\n" is, of course, the newline character ('\n').
When you close the output stream, you can then act on the returned status and any interesting content that you get back. The HttpURLConnection is simply doing automatically exactly what you'd do in a browser and getting back the same data stream (which it conveniently picks apart for you). Even the cookies are handled for you.
The one restraint is that the server you're contacting MUST be the same server that the applet wsa loaded from or you'll need a signed applet because of standard sandbox restrictions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic