wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes Apache httpClient Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Apache httpClient" Watch "Apache httpClient" New topic

Apache httpClient

Niko Nigde

Joined: Dec 06, 2012
Posts: 3

I am trying to log onto http://mobile.lufthansa.com using apache HttpClient.

Ist there anyone out there who could give me a help or at least a hint?

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(

HttpResponse response1 = httpclient.execute(httpGet);

try {
HttpEntity entity1 = response1.getEntity();

} finally {

//working fine so far but then...
HttpPost httpPost = new HttpPost(
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("userid", "xxxx"));
nvps.add(new BasicNameValuePair("password", "xxxx"));
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
HttpResponse response2 = httpclient.execute(httpPost);

is giving me a 302 error all the time. I believe it has something to do with the session as the form method calls:

but i lack the experience to know how to handle this.

Thank you in advance!

William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

Did you read about what 302 means?


Niko Nigde

Joined: Dec 06, 2012
Posts: 3
I know what 302 means, and that was not my question.
Thank you
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

So now I don't know what your question is. You say you know what the HTTP 302 response code, even though you called it an "error" in your original post. (It isn't an error code.) So given that you know what it means, you should be able to implement it by sending a new request to the location specified in the response. Did you try that?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41114
The HttpClient docs even have a web page about that: http://hc.apache.org/httpclient-3.x/redirects.html

Ping & DNS - my free Android networking tools app
I agree. Here's the link: http://aspose.com/file-tools
subject: Apache httpClient
Similar Threads
How to return a parameter from a servlet to the calling HttpClient
HttpClient login, search and get the HTML content
Site Authorization using HttpClient: cannot receive cookie.
unable to login to a website. tried both httpclient and defaulthttpclient
getParameter in jsp file sent by HttpClient