Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 54924 invoked from network); 7 Feb 2005 21:11:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Feb 2005 21:11:50 -0000 Received: (qmail 19895 invoked by uid 500); 7 Feb 2005 21:11:46 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 19778 invoked by uid 500); 7 Feb 2005 21:11:45 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 19764 invoked by uid 99); 7 Feb 2005 21:11:45 -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 parfw01-nat.parago.com (HELO PAREXC01.ad.parago.com) (216.206.147.99) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 07 Feb 2005 13:11:44 -0800 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Subject: [httpclient]- How to send and recieve Serialized Object using Http Client Date: Mon, 7 Feb 2005 15:11:42 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [httpclient]- How to send and recieve Serialized Object using Http Client Thread-Index: AcUNSbwwVqjA+lk2Rc2xfIWU5YfQvwADWzyAAAA0t2AAAGLhgA== From: "Sanjeev Tripathi" To: "Jakarta Commons Developers List" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Is there Any way I can retrieve object that I set in servlet using request.setAttruibute("name", object); And vise versa can I send from Client Side to servlet similar way as we send=20 Other string parameter as follows PostMethod authpost =3D new PostMethod("/argo/XmzServlet"); NameValuePair action =3D new NameValuePair("action", "login"); NameValuePair url =3D new NameValuePair("url", "argo/index.html"); NameValuePair userid =3D new NameValuePair("LOGIN_NAME", "login"); NameValuePair password =3D new NameValuePair("LOGIN_PASSWORD", = "passwd"); NameValuePair thickClient =3D new NameValuePair("ThickClient", "ThickClient"); authpost.setRequestBody( new NameValuePair[] {action, url, userid, password,thickClient}); thanks. -----Original Message----- From: Sharples, Colin [mailto:Colin.sharples@contact-energy.co.nz]=20 Sent: Monday, February 07, 2005 2:57 PM To: Jakarta Commons Developers List Subject: Spam: RE: Http Client- How to send and recieve Serialized Object using Http Client Assuming it's not just because of the typo in the content type (should be "application/octet-stream"), you could try base 64 encoding the object output stream, and then you can just use text/plain content type. On the other end you base 64 decode the response body before passing it to the object input stream. There are plenty of examples of how to do base 64 encode/decode on the web. Colin Sharples IBM Advisory IT Specialist Email: sharples@nz.ibm.com > -----Original Message----- > From: Sanjeev Tripathi [mailto:sanjeev.tripathi@parago.com] > Sent: Tuesday, 8 February 2005 8:18 a.m. > To: commons-dev@jakarta.apache.org > Subject: Http Client- How to send and recieve Serialized Object using > Http Client >=20 >=20 > Hi, >=20 > =20 >=20 > I am working on thick client proxy that will connect to servlet and > retrive and save data to database. I am using Http Client for > communication. >=20 > =20 >=20 > I am able to send string values using parameter in request=20 > as follows.=20 >=20 > =20 >=20 > //************************************************************ > ********** > **** >=20 > NameValuePair userid =3D new NameValuePair("LOGIN_NAME", > "login"); >=20 > NameValuePair password =3D new NameValuePair("LOGIN_PASSWORD", > "password"); >=20 > NameValuePair thickClient =3D new NameValuePair("ThickClient", > "ThickClient"); >=20 > =20 >=20 > authpost.setRequestBody( >=20 > new NameValuePair[] {action, url, userid, > password,thickClient}); >=20 > =20 >=20 > //************************************************************ > ********** > **** >=20 > =20 >=20 > I am able to send xml string as parameter and able to receive it back > from response as String. >=20 > =20 >=20 > But I am getting problem in serialized user defined objects > communication. Following is not working >=20 > =20 >=20 > =20 >=20 > =20 >=20 > //*************************In Servlet***************** >=20 > =20 >=20 > if (request.getParameter("ThickClient").equals("ThickClient")) { >=20 > =20 >=20 > =20 >=20 > response.setContentType("application/octel-stream"); >=20 > ObjectOutputStream oos =3D new > ObjectOutputStream(response.getOutputStream()); >=20 > oos.writeObject(new=20 > com.parago.communication.SubmissionVO(1,"Controll > Servlet")); >=20 > =20 >=20 > oos.flush(); >=20 > oos.close(); >=20 > return; >=20 > } >=20 > =20 >=20 > =20 >=20 > =20 >=20 > =20 >=20 > ******************** In Thick Client Proxy ************************* >=20 > =20 >=20 > =20 >=20 > =20 >=20 > client.executeMethod(authpost); =20 >=20 > =20 >=20 > System.out.println("Login form post: " + > authpost.getStatusCode()); >=20 > ObjectInputStream ois =3D new > ObjectInputStream(authpost.getResponseBodyAsStream()); >=20 > SubmissionVO vo =3D (SubmissionVO)ois.readObject(); >=20 > System.out.println("id :" +vo.getSubmissionId() +": desc:" + > vo.getDescription()); >=20 > =20 >=20 > =20 >=20 > =20 >=20 > //******************Here SubmissionVO is Serialized Object*********** >=20 > =20 >=20 > public class SubmissionVO implements java.io.Serializable{ >=20 > public SubmissionVO(int id,String desc) { >=20 > this.submissionId =3D id; >=20 > this.description =3D desc; >=20 > } >=20 > private int submissionId; >=20 > private String description; >=20 > =20 >=20 > public int getSubmissionId () { >=20 > return submissionId; >=20 > } >=20 > public String getDescription() { >=20 > return description; >=20 > } >=20 > } >=20 > //*********************************************************** >=20 > =20 >=20 > =20 >=20 > =20 >=20 > =20 >=20 > Please suggest me. How to send and receive Serialized User=20 > Defined Value > Objects in using Http Client. >=20 > =20 >=20 > =20 >=20 > =20 >=20 > Thanks. >=20 > =20 >=20 > Sanjeev Tripathi >=20 > =20 >=20 > =20 >=20 > =20 >=20 > =20 >=20 > =20 >=20 >=20 > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email=20 > ______________________________________________________________________ >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org