views:

1332

answers:

5

Wich are the main differences between the two?

thanks

+4  A: 

Heres a chart that compares their capabilities.

It also appears that HttpUrlConnection is much faster.

Brandon
Note that the chart provided is from 2001. There's at least one inaccuracy, the last one about the source not being available for HttpURLConnection.
Rob Hruska
It is actually bad form to link to that chart, it refers to an HTTPClient implementation that is not Apache's and the link is 9 years old!
Max Howell
+3  A: 

Which HTTPClient ? There are two!

For the record, I've used both with success. The Commons version certainly has a wealth of configuration options and is broken down into a decent component hierarchy. I can't remember the details of the innovation.ch version.

Brian Agnew
+1  A: 

The Apache version links to http://www.oaklandsoftware.com/product_http/compare.html for a 'fair' comparition of implementations

MegaTux
+1  A: 

The one is from the standard Java SE API and the other is a Apache Commons library which is built on top of the standard Java SE one. Apache Commons libraries in turn are usually more convenienced and less opaque (read: less low-level).

In fact, everything can be done with the standard Java SE API. Major goal of those kind of libraries are just faster development and lesser code. In this particular example you can for instance send a POST request with just one or two HttpClient methods instead of writing 10~20 lines of code as you would do with plain HttpUrlConnection. The same story applies on the Apache Commons IO v.s. java.io and Apache Commons Lang v.s. java.lang, Apache Commons Collections and Google Collections v.s. Java Collections, etcetera.

BalusC
is Apache HttpClient (v4) really built on top of HttpURLConnection?
Matthias
A: 

Have a look at this page link httpclient vs. httpurlconnection

Junior Software Developer