hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidecr <david...@gmail.com>
Subject Re: Help on Requst Params in Post
Date Mon, 10 Apr 2006 17:07:02 GMT
Roland Weber wrote:
> 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
> pieces.
>
> 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
>
>
>   
Thanks for the explanation Roland. I forgot to something and maybe 
appropriate now... I'm only using ASCII characters... I dont use even 
spaces or any character that must be encoded... so the approach I use is 
to keep a file with all constants ... for parameters names and keep a 
reference to this class from the server and the client...

Something like:

public interface ParametersConstants {

    String ACTION = "action";
    String CLIENT_GET_CONTACTS = "clientGetContacts";
    String CLIENT_GET_LIST = "clientGetList";
    String CLIENT_ADD_NEW = "clientAddNew";
    String CLIENT_DELETE = "clientDelete";
    String CLIENT_UPDATE = "clientEdit";

... etc

}

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