• 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
Bartender
Posts: 18469
61
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.
 
See where your hand is? Not there. It's next to this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!