hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Han <xx...@health.state.ny.us>
Subject RE: postmethod does not work
Date Wed, 31 Oct 2007 15:31:32 GMT

Hi Roland,

Actually I once used the following code to set it:

               ServletInputStream sis=  request.getInputStream();
     	  int len=request.getContentLength();
     	  String conten_type=request.getContentType();
               httppost.setRequestContentLength(len);
               httppost.setRequestHeader("Content-type",content_type); 
               InputStreamRequestEntity re= new
InputStreamRequestEntity(sis);
               httppost.setRequestEntity(re);


But it still did not work. (Later I thought the content-type should be by
default "'application/x-www-form-urlencoded", so you didn't see it in my
post, but even it is there it still doesn't work)

Thanks,

Han



Roland Weber wrote:
> 
> Hello Han,
> 
>>_    	    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);
> 
> 
> Where do you set the Content-Type header for the
> request you are sending? Without that header, the
> target servlet can't know that you are sending
> parameters.
> Sorry for sending you off on the wrong trail.
> 
> cheers,
>   Roland
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/postmethod-does-not-work-tf4719655.html#a13511884
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message