You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by ever friend <ev...@yahoo.com> on 2008/03/03 02:57:36 UTC

httpclient4 app cause serverside-servlet request.getparameter() return null?

Greeting....
   
  New to httpclient4.
  Have a problem when I tried to udpate my application from httpclient3.x to httpclient4.
  I got the error at server side: 
request.getParameter("paraName") returns null. 
  (serverside is an applicaiton running on Jboss).

  Here is the code on client side: 
// prepare parameters 
HttpParams params = new BasicHttpParams(); 
params.setParameter("paraName", "test"); 
HttpClient httpClient = new DefaultHttpClient(); 
  httpPost = new HttpPost("http://www.mydomain.com/servletTest); 
httpPost.setParameter(params); 
HttpResponse response = httpClient.execute(httpPost); 
....... 
  The servletTest at server application does receive the http request, 
but when it calls request.getParameter("paraName"), it gets null. 
   
  Did I miss anything here? 
  When I use httpclient3.x for this kind of functions, it works fine. 
  Thank you for any feedback and help! 
  
 
  Best, 
  Ever 


       
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.

Re: httpclient4 app cause serverside-servlet request.getparameter() return null?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2008-06-19 at 11:06 -0700, Danny N wrote:
> Isn't this a bit of an object-oriented failure for HttpPost to inherit from
> the abstract class of AbstractHttpMessage when setParams(HttpParams params)
> does absolutely nothing?
> 

No, it is not. HttpParams have nothing to do with HTTP POST parameters.

Oleg



> 
> Roland Weber wrote:
> > 
> > Hello Ever,
> > 
> >>   Here is the code on client side: 
> >> // prepare parameters 
> >> HttpParams params = new BasicHttpParams(); 
> >> params.setParameter("paraName", "test"); 
> > 
> > HttpParams provides parameters to the HttpClient framework.
> > If you want send something to the server, put it in an
> > entity. The one you're looking for is this:
> > http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/client/methods/UrlEncodedFormEntity.html
> > 
> >>   When I use httpclient3.x for this kind of functions, it works fine. 
> > 
> > If you call PostMethod.getParams().setParameter(...) in 3.1,
> > it fails just as miserably ;-)
> > 
> > But we need to improve our documentation, quickly...
> > 
> > cheers,
> >    Roland
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > 
> > 
> > 
> 


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


Re: httpclient4 app cause serverside-servlet request.getparameter() return null?

Posted by Danny N <dn...@atrexis.com>.
Isn't this a bit of an object-oriented failure for HttpPost to inherit from
the abstract class of AbstractHttpMessage when setParams(HttpParams params)
does absolutely nothing?


Roland Weber wrote:
> 
> Hello Ever,
> 
>>   Here is the code on client side: 
>> // prepare parameters 
>> HttpParams params = new BasicHttpParams(); 
>> params.setParameter("paraName", "test"); 
> 
> HttpParams provides parameters to the HttpClient framework.
> If you want send something to the server, put it in an
> entity. The one you're looking for is this:
> http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/client/methods/UrlEncodedFormEntity.html
> 
>>   When I use httpclient3.x for this kind of functions, it works fine. 
> 
> If you call PostMethod.getParams().setParameter(...) in 3.1,
> it fails just as miserably ;-)
> 
> But we need to improve our documentation, quickly...
> 
> cheers,
>    Roland
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/httpclient4-app-cause-serverside-servlet-request.getparameter%28%29-return-null--tp15796391p18014758.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: httpclient4 app cause serverside-servlet request.getparameter() return null?

Posted by ever friend <ev...@yahoo.com>.
Hi,Roland,
   
  Thank you for the help! got it.
  in httpclient3.x, I used postMethod.setRequestBody(data);
  but in httpclient4, I could not find it. I guess that's why I got problem to use httppost.setParams().
   
  Agree, the documentation does need a lot of improvement....
   
  Best,
   
  Ever
  


Roland Weber <os...@dubioso.net> wrote:
  Hello Ever,

> Here is the code on client side: 
> // prepare parameters 
> HttpParams params = new BasicHttpParams(); 
> params.setParameter("paraName", "test"); 

HttpParams provides parameters to the HttpClient framework.
If you want send something to the server, put it in an
entity. The one you're looking for is this:
http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/client/methods/UrlEncodedFormEntity.html

> When I use httpclient3.x for this kind of functions, it works fine. 

If you call PostMethod.getParams().setParameter(...) in 3.1,
it fails just as miserably ;-)

But we need to improve our documentation, quickly...

cheers,
Roland



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



       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.

Re: httpclient4 app cause serverside-servlet request.getparameter() return null?

Posted by Roland Weber <os...@dubioso.net>.
Hello Ever,

>   Here is the code on client side: 
> // prepare parameters 
> HttpParams params = new BasicHttpParams(); 
> params.setParameter("paraName", "test"); 

HttpParams provides parameters to the HttpClient framework.
If you want send something to the server, put it in an
entity. The one you're looking for is this:
http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/client/methods/UrlEncodedFormEntity.html

>   When I use httpclient3.x for this kind of functions, it works fine. 

If you call PostMethod.getParams().setParameter(...) in 3.1,
it fails just as miserably ;-)

But we need to improve our documentation, quickly...

cheers,
   Roland



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