Login with  Log in with facebook
Hiring Manager? SIGN UP HERE
I am executing following sample program of httpclient of "GET" method.
 import org.apache.commons.httpclient.HttpClient; 
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;

public class TestMethodStatuscode
public static void main(String[] args) throws Exception
HttpClient client = new HttpClient();
HttpMethodParams.USER_AGENT, "Mozilla/5.0
(Windows; U; Windows NT 6.1; en-US; rv: Gecko/20100401 Firefox/3.6.3
(.NET CLR 3.5.30729)");
GetMethod get = new GetMethod("http://de.mg40.mail.yahoo.com/neo/launch?.rand=80g4u84m26ifl");
System.out.println("Status code: "+get.getStatusCode());
//System.out.println(get.getResponseBodyAsString()); get.releaseConnection();

output:- Status code: 200

The url I am trying to fetch is some url which I get during process of login to yahoo.de email account.(login to yahoo.de did not work for me so was trying this code). If I enable wireshark(filter-http or (http.request.method == POST or http.request.method == GET) and then type this url in browser , press enter and finally I notice in wireshark that the return code of the above url is 302 which means it is redirected. Also when I run my program and check in wireshark, I see that method returns the code 302. So my queston is why it is giving me 200 as a statuscode as output and not 302 ?

I am kind of stuck here and dont know what to do..Any help would be highly appreciated.


Dewasish Mitruka
07/08/2011 at 05:34
If you want to post any answer to this forum then you need to log in.
Schedule a Demo

Schedule a Demo with us

Name *
Email *
Phone *
Company *