someone please give me some hints or ideas.
...
i don't want it to use a POST or GET commands, i don't want it to pass the values through the URL.
I want my program to act like a user , i want it to open a form, fill it up, and then press the submit button.
Regards
hsn
Please note: If a user presses the submit-button then exactly that happens: the system sends a POST or GET request. (I know that here are also some other exotic ways and browsers, but I speak of the common case). So your question is like saying I want to make a fried egg, but I don't want to use a raw egg and I don't want to use a pan for that which would be the simplest way. So literally speaking, your only option then is to get a cook that does it for you.
How to get a cook:
Just use a Windows macro recorder (like Easy Macro Recorder or so) and start it. Then open your explorer, go to the page, fill out the values, press submit and then stop the recorder. It produces a file which you can then easily execute in your java program with Runtime.exec().
But if you want to fry your eggs yourself, which I would prefer, here is the source code of a program that sends a POST-request and gets the response page back (the HTML source code is contained in the return string). Then you can parse that string for any result you are interested in. It is quite old and uses a non-blocking HTTPClient.jar-file for the request, but you can also do it in a similar way with the java.net.URL class which are include in the newer java versions.
For example you are on google-site, enter "easy makro recorder" and press "submit". Then the browser send a request like that:
"http://www.google.com/search?q=easy+makro+recorder".
Now the java program that does it for you:
- import HTTPClient.HTTPConnection;
-
import HTTPClient.HTTPResponse;
-
import HTTPClient.CookieModule;
-
-
String urlWithValues = "search?q="+ URLEncoder.encode("easy makro recorder");
-
String host = "64.233.167.99"; // = google.com. You can also use InetAddress.getByName("google.com") instead.
-
String port = "80";
-
HTTPConnection connection = new HTTPConnection(host, port);
-
HTTPResponse response = connection.Post(urlWithValues);
-
-
InputStream input = response.getInputStream();
-
BufferedReader dataInput = new BufferedReader(new InputStreamReader(input));
-
String searchResults = "";
-
while (true)
-
{
-
String line = dataInput.readLine();
-
if (line == null) break;// end of response
-
searchResults += line;
-
}
-
-
System.out.println("google found following results:" + searchResults);