Home arrow static arrow Java Programming [Archive] - using HttpUrlConnection
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - using HttpUrlConnection
This topic has 1 reply on 1 page.

Registered: 6/21/04
using HttpUrlConnection  
Aug 6, 2004 3:52 PM

I need to send and receive messages to/ from a URL from within a Java program. However, I do not know what to send the URL to mimick pressing a button or choosing from a menu. Can anyone who knows http tell me where I can find what commands get sent to a URL when buttons get pressed and menus are selected from? Does looking at the html document for the website help? Also, what functions of HttpUrlConnection should I use to send the information? Also, if this is something that is difficult to figure out for an http novice, can anyone suggest any good resources? Thanks.

Registered: 2/22/00
Re: using HttpUrlConnection  
Aug 6, 2004 4:29 PM (reply 1 of 1)

Didn't we talk about this a couple days ago?

Anyway, looking at the web page souce will help. But you'll need to know HTML to interpret what you're looking at. Knowing related technologies, if only to the extent that you're able to identify them, will help too.

Also it would be good to learn about the HTTP spec (read the RFC), in particular the parts about query string arguments and post data.

But basically it goes like this. If you have this very simple web page:
<html>  <body>    <form action="http://www.something.com/something.cgi">      <input type="text" name="monkeyName">      <input type="checkbox" name="angry" value="yes">      <input type="submit">    </form>  </body></html>

Then the browser will submit to the URL something like

and if the form had "METHOD="POST"" added to the <form> tag, it would just post to something.cgi and the stuff after the question mark would appear as HTTP submission content, which corresponds to the output stream you can write to in HttpUrlConnection object.

Your java code has to create data in that format. So really it's just sending data; the java code doesn't really have to know what the "button" widget on the HTML does.

Javascript can make it somewhat more complicated. Flash and applets make it much more complicated.
This topic has 1 reply on 1 page.