hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Problem by getting request entity on server side
Date Fri, 17 Aug 2007 12:57:49 GMT
On Fri, 2007-08-17 at 03:28 -0700, Pengqian wrote:
> Hi,
> i am new to HttpClient, so it might be a simply question to somebody.
> i want to send some serializeable data(not only some String) to the server
> per PostMethod, so i do following at client side:
> Hashtable table = new Hashtable();
> table.put("name", "XXX");
> table.put("RequestObject", serializeableObject );
> byte[] buf = SerializationUtils.serialize(table);
> PostMethod.setRequestEntity(entity);
> client.executeMethod(PostMethod);
> and at the server side:
> byte[] buf = new byte[servletRequest.getContentLength()];
> servletRequest.getInputStream().read(buf); 

This is a completely wrong way of reading from an input stream. Please
refer to some documentation on working with Java's I/O streams. This
article may be a reasonable start:



> Hashtable table = (Hashtable) SerializationUtils.deserialize(buf);
> in this way i can not get the Hashtable again at server side. Logging
> message shows that everytime there is always a different content received
> from client than the original hashtable made by client. i can not get the
> right content from request entity made by client.
> could anyone please help me?
> thanks and regards

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

View raw message