Hi, Sometimes I find a website that gives an unexpected response. Usually I drop HttpClient for the basic java.net approach, but this time that did not work too! Somehow HttpClient posts a form different than IE and Mozilla. How exactly i do not know - but maybe I am just doing something wrong in these particular cases.
Below is an example of a website that works in IE/Mozilla, but it does not in HttpClient Copy paste this simple HTML to a local html file and execute it: <html><body> <form action="http://www.marinusjansen.nl/asp/search.asp" method="post"> <input name="soortpand" value="0"/><input name="prijsklasse" value="0"><input value="Search" type="submit"> </form></body></html> You will see a list of houses will be returned by the (www.marinusjansen.nl) webserver. - if you change post into get - no results are returned (actually most webservers don't care about that). - cookies and referer are of no influence to this webserver's behaviour (i tried that already). If you run HttpClient on this - the webserver will return something completely different. Try this in you favorite IDE HttpConnection httpCon = new HttpConnection("www.marinusjansen.nl", 80); HttpMethodBase http = new PostMethod(); NameValuePair nvp[] = new NameValuePair[2]; nvp[0] = new NameValuePair(); nvp[0].setName("soortpand"); nvp[0].setValue("0"); nvp[1] = new NameValuePair(); nvp[1].setName("prijsklasse"); nvp[1].setValue("0"); http.setQueryString(nvp); http.setPath("/asp/search.asp"); HttpState state = new HttpState(); http.execute(state, httpCon); System.out.print(http.getResponseBodyAsString()); Has anybody a suggestion how i can get this to work? (For those who have trouble reading Dutch... The expected response is a list of properties, but with HttpClient the response is: 'Cannot find any listings'). Regards, Jaap ___________________________________ jaap - yawi amsterdam science park kruislaan 402 1098 sm amsterdam the netherlands m: +31 6 4540 2828 t: +31 20 888 4836 f: +31 20 888 4838 [EMAIL PROTECTED] http://jaap.nl http://yawi.nl --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
