tags:

views:

150

answers:

2

Actually I want to submit a html Form through java code.

i use Apache HttpClient API Post method for this but when i send the request it return me same page with filled form instead of submitting it.

When i open that Html Form which i want to submit through java code i came to know that it has a ajax call to submit.

i want to know how can i send that ajax call also from java code .

i will really appreciate any help in this regard.

+1  A: 

Easiest way is to invoke the same HTTP request as the Ajax request did. Just read the JS code yourself, filter the URL out of it and populate the parameters as the Ajax request did -just use a HTTP header tracker (Firebug?) to get them all.

Hardest way is to simulate (reinvent) the average webbrowser in low-level. That is, download/interpret JavaScripts and execute them as well. This way you don't need to worry about JS/Ajax code at all and just invoke the plain HTTP request. Needless to say that this is after all fairly cumbersome.

If you actually want a webapplication testing tool, have a look at Selenium.

If this webapplication is actually not yours, then I hope that you have read their robots.txt to ensure that you didn't violate the law.

BalusC
A: 

The Live HTTP Headers extension for Firefox is really useful for seeing what is actually going on, as is FireBug. Using these you should be able to see what the Ajax is doing that your user agent is not.

ZoFreX