From commons-user-return-10768-apmail-jakarta-commons-user-archive=jakarta.apache.org@jakarta.apache.org Tue Feb 08 19:55:03 2005 Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 17872 invoked from network); 8 Feb 2005 19:55:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Feb 2005 19:55:03 -0000 Received: (qmail 31018 invoked by uid 500); 8 Feb 2005 19:54:59 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 30998 invoked by uid 500); 8 Feb 2005 19:54:59 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 30985 invoked by uid 99); 8 Feb 2005 19:54:59 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from metalexis.com (HELO metalexis.com) (200.46.204.192) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 08 Feb 2005 11:54:57 -0800 Received: from [192.168.1.101] (12-216-42-41.client.mchsi.com [12.216.42.41]) by metalexis.com (Postfix) with ESMTP id 79A62A463A1 for ; Tue, 8 Feb 2005 19:54:52 +0000 (GMT) Message-ID: <420918FB.9030500@metalexis.com> Date: Tue, 08 Feb 2005 13:54:35 -0600 From: Matt Goodwin User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Users List Subject: Re: [httpclient] Sending serialized object from httpclient to servlet. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N From the Java Developers Almanac site http://javaalmanac.com/egs/java.io/SerializeObj.html // 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 Matt Goodwin mgoodwin@metalexis.com (515)708-0114 "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 >sun.misc.BASE64Encoder().encode(password.getBytes()) > > >Thanks. >Sanjeev Tripathi > >-----Original Message----- >From: Wendy Smoak [mailto:java@wendysmoak.com] >Sent: Tuesday, February 08, 2005 10:23 AM >To: commons-user@jakarta.apache.org >Cc: Jakarta Commons Developers List >Subject: Re: [httpclient] Sending serialized object from httpclient to >servlet. > >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): >http://www.mail-archive.com/commons-dev%40jakarta.apache.org/msg57055.ht >ml > >For general information on base 64 encoding: >http://www.google.com/search?q=java+base64+encoding > >Here's Jakarta Commons Codec, which includes a base 64 encoder: >http://jakarta.apache.org/commons/codec/ >http://jakarta.apache.org/commons/codec/apidocs/org/apache/commons/codec >/binary/Base64.html > >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 >as >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: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org