hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "liu gang" <ggliu...@hotmail.com>
Subject http status 400 error
Date Wed, 08 Jan 2003 11:43:43 GMT

I am working with the nightly build commons httpclient on the 28th 
December.
I want to write a program to logon on a website automatically and test it 
on the tomcat admin system.
the code was as follows:

 //---------------------------------------
 URL url = new URL("http://127.0.0.1:8080/admin/j_security_check");
 
 HttpClient client = new HttpClient();
 client.setconnectionTimeout(5000);
 HostConfiguration hc = new HostConfiguration();

 //url is URL of a login servlet.
 hc.setHost(new URI(url));
 client.setHostConfiguration(hc);

 PostMethod method = new PostMethod(url.getPath());
 method.setFollowRedirects(true);
 method.setStrictMode(false);
        
 method.addParameter("j_username","admin");
 method.addParameter("j_password","admin");
 client.executeMethod(method);
 byte[] responseBody = method.getResponseBody();
 System.out.println(new String(responseBody));
        
 method.releaseConnection();
//-------------------------------------------

but error of Http status 400 occured. 
part of the console output is as follows:

<h1>HTTP Status 400 - Invalid direct reference to form login page</h1><HR 
size="1" noshade><p><b>type</b> Status report</p><p><b>message</b>

<u>Invalid direct reference to form login page</u></p><p><b>description</b>

<u>Therequest sent by the client was syntactically incorrect (Invalid 
direct reference to form login page).

Do some people know why?

thanks in advance!

liugang
2003/1/8


_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn 


Mime
View raw message