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
IMPORTANT NOTICE: This e-mail and any attachments may contain confidential or
sensitive information which is, or may be, legally privileged or otherwise
protected by law from further disclosure. It is intended only for the
addressee. If you received this in error or from someone who was not
authorized to send it to you, please do not distribute, copy or use it or any
attachments. Please notify the sender immediately by reply e-mail and delete
this from your system. Thank you for your cooperation.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]