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 Ramit Bhardwaj <ra...@cybage.com> on 2006/02/03 15:52:40 UTC
How to set Attributes in post request
Hi guys,
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 ?
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: How to set Attributes in post request
Posted by Roland Weber <ht...@dubioso.net>.
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