Hello,
I have a problem when the HttpClient try to post some simple form data to an
external Servlet.
The form data comes from this simple jsp:
////// ***** index.jsp ***** //////////////////////////
<form method="POST" action="PreSend">
<input type="hidden" name="year" value="2007">
<input type="hidden" name="sex" value="male">
<input type="submit" value="Submit" name="submit">
</form>
//////////////////////////////////////////////////////
And the PreSend servlet deals with the request without any problem:
//////////// ***** PreSend.java *****
//////////////////////////////////////////////////
webpage="http://m168.com/test_servlet";
HttpClient client = new HttpClient();
PostMethod httppost = new PostMethod(webpage);
ServletInputStream sis= request.getInputStream(); ///these 2 line
can
be replaced by set RequestEntity***
httppost.setRequestBody(sis); // *** ****************************
client.executeMethod(httppost);
////// ***** or use new api in version 3.1: *****/////////
//InputStreamRequestEntity re= new InputStreamRequestEntity(sis);
//httppost.setRequestEntity(re);
///////////////////////////////////////////////////////////////////////////////////////
However, after the PreSend servlet POST the request to test_servlet,
test_servlet just cannot get any data from its request object.
//////////// ***** test_servlet.java *****
//////////////////////////////////////////////////
Enumeration em=request.getParameterNames();
String paramName="";
while(em.hasMoreElements())
paramName = (String)em.nextElement();
///////////////////////////////////////////////////////////////////////////////////////
I mean, after control goes to test_servlet, the above paramName is always
empty.
Please give me a hint about what is wrong here.
Thanks for you help!
Han
--
View this message in context:
http://www.nabble.com/postmethod-does-not-work-tf4719655.html#a13492276
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]