Hi,
I wrote a method which requests a resource several times from on a servlet 
server (on localhost). 
It seems to me that the version using HttpClient is abouot a factor of 20-30 
slower than the 
version based on Sun's HttpURLConnection. I cannot believe these figures and 
ask you, where 
I misused the HttpClient class. If the result is correct, what is the reasen 
that HttpClient
is slower?

The HttpClient method looks as follows:

        static void doJakartaCommons(String path) throws Exception {
                HttpClient client = new HttpClient();
                for (int i = 0; i < 1000; i++) {
                        HttpMethod method = new GetMethod(path);
                        client.executeMethod(method);
                        int code = method.getStatusCode();
                        if(code != 200)
                                throw new IllegalStateException();
                        method.releaseConnection();
                }
        }


The version bsaed on HttpURLConnection looks as follows:

        static void doHttpConnection(String path) throws Exception {
                for (int i = 0; i < 1000; i++) {
                        URL url = new URL(path);
                        HttpURLConnection c = (HttpURLConnection) 
url.openConnection();
                        c.connect();
                        int code = c.getResponseCode();
                        if(code != 200)
                                throw new IllegalStateException();
                }
        }


Thanks for your help.
Dominik




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to