commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Goodwin <>
Subject Re: [httpclient] Sending serialized object from httpclient to servlet.
Date Tue, 08 Feb 2005 19:54:35 GMT
 From the Java Developers Almanac site

// Serialize to a byte array ByteArrayOutputStream bos = new 
ByteArrayOutputStream() ;
out = new ObjectOutputStream(bos) ;
 out.writeObject(object); out.close();
 // Get the bytes of the serialized object byte[] buf = bos.toByteArray();

Hope that's what you were looking for.


Matt Goodwin
"Transcending the Ordinary"

Sanjeev Tripathi wrote:

>Thanks Wendy.
>  I know how to serialize object to file or socket. But How I can
>convert object to bytes so I can use
>byte[] encodedData = Base64.encodeBase64( binaryData );
>could you give a example of it.
>I used this for strings but I am stuck for object
>String encodedPassword = new
>Sanjeev Tripathi
>-----Original Message-----
>From: Wendy Smoak [] 
>Sent: Tuesday, February 08, 2005 10:23 AM
>Cc: Jakarta Commons Developers List
>Subject: Re: [httpclient] Sending serialized object from httpclient to
>From: "Sanjeev Tripathi" <>
>>Can any one tell me how send serialized object to
>>servlet from httpclient.
>Colin already gave you one option, (base 64 encoding the binary data):
>For general information on base 64 encoding:
>Here's Jakarta Commons Codec, which includes a base 64 encoder:
>Without actually trying it, it looks like all you need to do is:
>     byte[] encodedData = Base64.encodeBase64( binaryData );
>Then turn the byte[] into a String and POST it to the server as the
>value of
>a request parameter.  If it's not too big, it should work the same way
>sending a big string from a text area.
>The 'commons-dev' list is usually reserved for questions about the
>development of the libraries themselves, so I'm replying to commons-user
>(and copying dev).

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message