hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <http-as...@dubioso.net>
Subject Re: passing object
Date Thu, 08 Jun 2006 17:44:21 GMT
Hello Michael,
> 
> Is that a correct way to do that like this:
> 
> In client side, serializing object to string and send it as URL post
> parameter.
> 
> In the server side, de-serializing the string to object.

Almost correct. But you serialize to a byte array, not a string.
And you don't send it as a parameter, unless you want to pass
other parameters as well. If the serialized object(s) is all you
want to send, you send the byte array as the request entity.
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/ByteArrayRequestEntity.html

If you want to have an advanced design, you can implement the
request entity interface directly and serialize the object to
the output stream in writeRequest(...):
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/RequestEntity.html

If you want to pass additional parameters with your serialized
object, your options are:
a) send them as query parameters in the URL
b) use a multipart request entity and serialize to a PartSource
   instead of a ByteArrayRequestEntity

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/ByteArrayPartSource.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


Mime
View raw message