You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Sanjeev Tripathi <sa...@parago.com> on 2005/02/09 17:54:18 UTC

RE: [httpclient] How to send and recieve Serialized Object usingHttpClient

Actually request parameter that I set in HttpCleint I can use in servlet
But
There is no way (or at least I don't know) to retrieve request
attribute/parameter in http client those set in servlet. This is very
simple in jsp but in http client I need to write object to
outputstream{ObjectOutputStream oos = new
ObjectOutputStream(response.getOutputStream())}

To work this I need to set content type as follows

response.setContentType("application/octet-stream");

I don't want to set content type "application/octet-stream" that's our
goal.

Every thing is fine in client side.

Thanks.
Sanjeev Tripathi


-----Original Message-----
From: Wendy Smoak [mailto:java@wendysmoak.com] 
Sent: Wednesday, February 09, 2005 10:23 AM
To: Sanjeev Tripathi; commons-user@jakarta.apache.org
Subject: Re: [httpclient] How to send and recieve Serialized Object
usingHttpClient

From: "Sanjeev Tripathi" <sa...@parago.com>
> I am able to send object as string same way as you suggested from http
> client but from servlet I still need to use content type to
> "application/octet-stream" to receive object in httpclient side but I
> want to use content type "text/plain" in servlet.
> If I write object as byte on respose that object I am not able to
receive.
> It is giving "invalid header" error in http client side. But I will
try
> Matt's way and let you know.

If you post the code you're using, someone can probably help.  I'm quite
lost by now trying to remember who suggested what.

If you're getting all the way to the base64 encoded byte[], can't you
turn
it into a String and then use that as the value of a request parameter
for
the POST?  Wasn't that the original goal, to serialize an object,
base-64
encode the binary data, and send it to the server as text?

If so, there's a String constructor that takes a byte[], (and you can
specify the charset if necessary).

HTH,
-- 
Wendy Smoak


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


Re: [httpclient] How to send and recieve Serialized Object usingHttpClient

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Sanjeev Tripathi" <sa...@parago.com>
> Actually request parameter that I set in HttpCleint I can use in servlet
> But
> There is no way (or at least I don't know) to retrieve request
> attribute/parameter in http client those set in servlet. This is very
> simple in jsp but in http client I need to write object to
> outputstream{ObjectOutputStream oos = new
> ObjectOutputStream(response.getOutputStream())}
> To work this I need to set content type as follows
> response.setContentType("application/octet-stream");

Can you list the steps you're taking, and post the code that is not working?

I _think_ you're stuck on sending a base 64 encoded serialized object back
to the client, but I'm not certain.  If that's the case, please show the
server-side code you're using to send the response, and then what you've
done on the client.

-- 
Wendy Smoak


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