hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Natarajan_Va...@emc.com
Subject Send/Receive serialized object using Apache's httpclient package
Date Tue, 18 Mar 2008 01:21:37 GMT
Hi,

Is it possible send/receive serialized object using HttpClient? 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");
        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;
        }
        finally
        {
            post.releaseConnection();
        }
    }

Any help is appreciated.

Thanks
-Valli

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message