hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juanjo" <juanjog...@telefonica.net>
Subject redirection in 4.0
Date Tue, 10 Nov 2009 07:48:03 GMT
    In windows using tomcat 6.0 and jdk 1.6, my program runs properly. It
connect to a website by post, sending parameters, that return a 302. Then,
It reads the Location head an makes a Get call. 
    When I deploy this program in linux with tomcat 5, the location head
returns the home url, not the right one.
    This is the code:
    HttpClient client = new DefaultHttpClient();
    HttpPost req = new HttpPost(http://www.theweb.com);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("aaa","sss"));
    UrlEncodedFormEntity param = new UrlEncodedFormEntity(formparams);
    HttpResponse res = client.execute(req)
    entity =res.getEntity();
    Header loc = res.getFirstHeader("Location");
    Another program that do the same but no redirection and using
BasicResponseHandler runs properly in both systems.
Please help,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message