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: Help on Requst Params in Post
Date Mon, 10 Apr 2006 16:37:26 GMT
Hello Sheetal,

>   If I want to write params and as well objects,  
>   Should i use ByteArrayPart with StringPart, is this the right way.

Ok, so I take it you actually want to serialize Java objects and
send them to the server, along with some additional parameters.
The best way to do that is... it depends. If your parameters are
simple, that means not too many, not too big, ASCII character set.
Then you should use the approach David suggested:

1. put all parameters into the query string of the URL
2. implement a RequestEntity based on ObjectOutputStream.

on the server side, you can then access the parameters through
the Servlet API and put an ObjectInputStream around the request
body to deserialize your objects.

If your parameters are many, big, use a non-ASCII character set,
or if you feel uncomfortable with putting them into the URL for
any other reason, then you should create a multipart request
entity. Use StringPart for the parameters. Implement your own
ObjectsPart based on ObjectOutputStream - you can take FilePart
as the starting point and replace everything related to files
or the PartSource with new code that does object serialization.
There are only two or three methods you need to implement, most
of the logic is already implemented in the base class PartBase.
On the server side, you will need FileUpload or a similar
library to split the incoming request entity back into it's

hope that helps,

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

View raw message