I have code snippet like the following. After establishing a
connection, I need to steam content from database as post body. How do
I get a OutputStream from either HttpClient or PostMethod? With
java.net.URL I can use openConnection().getOutputStream(). However I
want to leverage the nice features of HttpCleint. In the following
code, I want to call the writeContent() method which should get huge
data from database.

Any help is appreciated.

        public static void main(String[] args)  throws Exception {
                HttpClient client = new HttpClient();
                PostMethod post = new 
PostMethod("http://myhost/service/consumer";);
                try {
                       //how to get a OutputStream to write my content?

                        int status = client.executeMethod(post);

                        System.out.println(post.getResponseBodyAsString());
                } finally {
                        post.releaseConnection();
                }               
        }
        public static void writeContent(OutputStream out) throws IOException {
                //data will be generated from database.
                out.write("<data><value>this</value></data>".getBytes());
        }
}

-- 
Zhaohua Meng
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to