commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sanjeev Tripathi" <sanjeev.tripa...@parago.com>
Subject RE: [httpclient] How to send and recieve Serialized ObjectusingHttpClient
Date Thu, 10 Feb 2005 17:59:52 GMT
Hi Wendy Smoak,

These are the steps:

In Http Client side:

byte[] decodeSevletData =
org.apache.commons.codec.binary.Base64.decodeBase64(authpost.getResponse
Body());

Vector servletVecoter = (Vector)
SerializationUtils.deserialize(decodeSevletData);
                                                           
for (int i = 0; i < servletVecoter.size(); i++) {
CommunicationVO vo = (CommunicationVO) servletVecoter.get(i);
System.out.println("id :" + vo.getSubmissionId() + ": desc:" +
vo.getDescription());}



In servlet side:


com.parago.communication.CommunicationVO commVO1 = new
com.parago.communication.CommunicationVO(45, "Object1");
            com.parago.communication.CommunicationVO commVO2 = new
com.parago.communication.CommunicationVO(75, "Object2");
            Vector commVOVector = new Vector();
            commVOVector.add(commVO1);
            commVOVector.add(commVO2);

byte[] encodedData =
Base64.encodeBase64(SerializationUtils.serialize(commVOVector));
//           String encodedString = new String(encodedData);

OutputStream os response.getOutputStream();
Os.write(encodedData);
os.flush();
os.close();
return;

Please tell me where I can improve this code as its not working.
Thanks.
Sanjeev Tripathi







-----Original Message-----
From: Wendy Smoak [mailto:java@wendysmoak.com] 
Sent: Wednesday, February 09, 2005 12:57 PM
To: Jakarta Commons Users List
Subject: Re: [httpclient] How to send and recieve Serialized
ObjectusingHttpClient

From: "Sanjeev Tripathi" <sanjeev.tripathi@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


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


Mime
View raw message