You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by liu gang <gg...@hotmail.com> on 2003/01/08 12:43:43 UTC

http status 400 error

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 


Re: http status 400 error

Posted by Ortwin Glück <or...@nose.ch>.
Please stop discussion on this issue now. Adrian has pointed out a 
possible cause of the problem and it is clear that it is not a problem 
of HttpClient. You may continue discussion somewhere else where it is 
more appropriate such as Usenet Group.

Odi


Re: http status 400 error

Posted by Michael Becke <be...@u.washington.edu>.
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:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>