hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ramit Bhardwaj" <ram...@cybage.com>
Subject RE: How to set Attributes in post request
Date Fri, 03 Feb 2006 15:21:15 GMT
yea..thats certainly helpful...but the catch is...that i am using version 2.0.2 so MultipartRequestEntity
 not avaliable and moreover...my requirement is to put data in a single post request...and
do not have more than one HTTP connection at a time..hence the dialema...any advice :(


-----Original Message-----
From: Roland Weber [mailto:http-async@dubioso.net]
Sent: Friday, February 03, 2006 8:39 PM
To: HttpClient User Discussion
Subject: Re: How to set Attributes in post request


Hi Ramit,

> i want to set a byte array as one of my attributes in the post request,
> similar to request.setAttribute(String,Object) in servlets? How do i
> acheive this ?

you can not set anything in a request similar to ServletRequest.setAttribute.
Request attributes on the server side are kept in memory and accessed as
Java objects. Whatever you put into an HTTP request needs to be sent over
a connection to the server, and as such you have to indicate where in the
request it should be put and what transformation/encoding to use. The two
concepts are really completely different.

Have a look at the MultipartRequestEntity and the PartSource interface.
You can feed your byte array in as a ByteArrayInputStream with an empty
or invented filename.
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/multipart/MultipartRequestEntity.html
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/multipart/PartSource.html

hope that helps,
  Roland

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


---------------------------------------------------------------------
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