File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "HTTP Request" Watch "HTTP Request" New topic

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
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.
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">
Filling in your name and clicking 'OK' on a page containing the code above will result in this url:
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

Joined: Nov 21, 2001
Posts: 22
I assume you're using Java ? The HttpURLConnection class in the 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.


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

Joined: Oct 04, 2001
Posts: 15
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
I agree. Here's the link:
subject: HTTP Request
It's not a secret anymore!