wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes HTTP Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "HTTP Request" Watch "HTTP Request" New topic
Author

HTTP Request

Tom Ben
Ranch Hand

Joined: Aug 17, 2001
Posts: 109
Can you connect to a web page from a application and have it enter information in the text fields and then submit the form?


Sun Certified Programmer on the Java 2 Platform
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I'm not sure if I understand what you mean. I interpret your question like this: You want to submit information to a form on a webpage without actually having to go to the page using your browser.
Try checking the source of the html page and look at the <form> tag.
It should have a method and an action attribute, the action tells you whether HTTP GET or HTTP POST is being used and action tells you where, i.e. what url, the result will be sent to.
Then check the names of the different input components and then you can simply send a query sting attached to the url specified by the action attribute.
Example:
A form where you submit your first and last name.
<form method="GET" action="www.somewhere.dom/input">
<input type=textfield name=fname>
<input type=textfield name=lname>
<input type=submit name="OK">
</form>
Filling in your name and clicking 'OK' on a page containing the code above will result in this url:
http://www.somewhere.dom/input?fname=John&lname=Doe
I hope this was useful information for you
Tom Ben
Ranch Hand

Joined: Aug 17, 2001
Posts: 109
You have the idea that I want put the form does POST. I wish it did a GET but does not.
Angus MacCuish
Greenhorn

Joined: Nov 21, 2001
Posts: 22
I assume you're using Java ? The HttpURLConnection class in the java.net package is what you're looking for. I use it regularly to Post data to servlets - the javadoc should tell you all you need to know.
Cheers
Gus


SCJP, SCJD, SCWCD, SCEA(I)
the_larch
Greenhorn

Joined: Feb 18, 2002
Posts: 1
I agree it is possible using the HttpURLConnection but i think it is too simple. You cant handle timeout for instance. So write a socket that performs a POST instead
allen turner
Greenhorn

Joined: Oct 04, 2001
Posts: 15
Hai
I am not sure if i should post this here. any way..
i want to make an application that can be used as a yahoo chat client and can i do that using java and if so how? i guess yahoo uses http for its chat
thanks
 
Don't get me started about those stupid light bulbs.
 
subject: HTTP Request