Ashok Venkat wrote:
Hi,
I have the following code in a scheduler class, which is trying to
invoke a servlet
String url = "https://localhost:8444/servlet/TestServlet";
// Get HTTP client instance
HttpClient httpClient = new HttpClient();
// Create HTTP GET method and execute it
GetMethod getMethod = null;
PostMethod postMethod = null;
int int_result = 0;
getMethod = new GetMethod( url );
getMethod.setFollowRedirects(true);
int_result = httpClient.executeMethod( getMethod );
String contents = getMethod.getResponseBodyAsString();
getMethod.releaseConnection();
postMethod = new PostMethod(
"https://localhost:8444/j_security_check" );
postMethod.addParameter( "j_username", "test" );
postMethod.addParameter( "j_password", "test" );
int_result = httpClient.executeMethod( postMethod );
contents = postMethod.getResponseBodyAsString();
postMethod.releaseConnection();
postMethod = new PostMethod( url );
postMethod.addParameter( "Password", "foo" );
int_result = httpClient.executeMethod( postMethod );
----------> At this point when the test servlet is called, the parameter password is null.
getParameter always returns null
getMethod returns GET when it should be post
It seems that the POST is behaving like a GET.
Why shouldn't it return null?
My reading (pre-morning coffee, admittedly) of this code would do the
following (in shorthand):
1. GET TestServlet -> 401 AUTH REQD
TestServlet does *not* execute, instead return a login request
2. POST j_security_check -> 200 OK
Login succeeds, forward to originally requested resource
TestServlet *does* execute, with original params(none) & GET method
3. POST TestServlet.(Password=foo)
TestServlet *does* execute, with params(Password=foo) & POST method
So, look further down in your logs, for the 2nd execution of TestServlet.
regards,
Pid
This code works just fine on tomcat 5.0. After upgrading to 6.0, i am seeing
this bizarre behaviour
Any thoughts?
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]