On Mon, 2008-03-17 at 21:22 -0400, [EMAIL PROTECTED] wrote:
> Hi,
>
> Is it possible send/receive serialized object using HttpClient?
Yes, it is
> I always
> get java.io.StreamCorruptedException: invalid stream header Exception.
>
> Here is my server side (servlet code)
>
> public void doPost (
> HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, IOException
> {
> response.setContentType("application/x-www-form-urlencoded");
Content type is wrong. This has nothing to do with HTML forms
> ObjectOutputStream oos = new
> ObjectOutputStream(response.getOutputStream());
> ArrayList l = new ArrayList();
> l.add("Index Server is running");
> oos.writeObject(l);
> }
>
> Client side code that access this servlet
>
> public OutputStream sendRequest (String method, HashMap args)
> throws IOException, IndexServerCommunicationException
> {
> PostMethod post = new PostMethod(m_url);
> try
> {
> post.setRequestEntity(new
> StringRequestEntity("something"));
> m_client.executeMethod(post);
> ObjectInputStream ois = new
> ObjectInputStream(post.getResponseBodyAsStream());
> return ois;
You _must_ not release the connection until you are done reading the
response body. No wonder you are getting StreamCorruptedException
Oleg
> }
> finally
> {
> post.releaseConnection();
> }
> }
>
> Any help is appreciated.
>
> Thanks
> -Valli
>
>
> ---------------------------------------------------------------------
> 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]