hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Becke <be...@u.washington.edu>
Subject Re: http status 400 error
Date Thu, 09 Jan 2003 05:12:03 GMT
The same thing happens if you hit this URL from a browser so I don't 
think this is a problem with HttpClient.  I'm not sure how to 
successfully authenticate outside of a browser though.  I've been 
trying for a little while now.  It seems there is something different 
between posting a HTML form to "/j_security_check" and doing a 
HttpClient.POST to the same URL with the same values.  My only guess is 
that there is something different in the headers.

Thoughts anyone else?

Mike

On Wednesday, January 8, 2003, at 06:43 AM, liu gang wrote:

>
> 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
>
> --
> To unsubscribe, e-mail:   
> <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:commons-httpclient-dev-help@jakarta.apache.org>
>


Mime
View raw message