HttpClient client = new HttpClient();
PostMethod post = new PostMethod(url); // buffer object to byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(object);post.setRequestBody(new ByteArrayInputStream(bos.toByteArray()));
try {
client.executeMethod(post);
ObjectInputStream in = new ObjectInputStream(post.getResponseBodyAsStream());
Object result = in.readObject();
} finally {
post.releaseConnection();
}
Mike
On Wednesday, October 15, 2003, at 11:02 PM, [EMAIL PROTECTED] wrote:
We are in the process of replacing the URLConnection class with HttpClient.
Currently we send serialized objects to a servlet with something similar to
the following code snippet:
URL url = URL(hostURL.getProtocol(), hostURL.getHost(), hostURL.getPort(), "/servlet/TestServlet"); URLConnection httpURLConnection = url.openConnection(); out = new ObjectOutputStream(httpURLConnection.getRequestOutputStream());
out.writeObject(serializedObject);
out.flush(); out.close()
-------------------------- (Meanwhile in the server)
The servlet reads the serializedObject from the InputStream of the HttpServletRequest parameter and sends the response in the HttpServletResponse
---------------------------(Back in the client) in = new ObjectInputStream( httpURLConnection.getResponseInputStream() ); result = in.readObject(); in.close();
I have tried to accomplish the same technique with HttpClient, but I have
been unsuccessful. Is this possible with this library?
Thank You Carlos R.
Carlos Javier Rivera Vazquez Staff Engineer GE Power Systems Network Reliability Services __________________________________________________
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
