This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

UrlConnections versus HttpURLConnection versus Apaches HttpClient  RSS feed

 
Cindy Jones
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to send a get request to a secure url and process the response.
The options that I have are java.net.UrlConnection, java.net.HttpUrlConnection and org.apache.commons.httpclient.HttpClient. What would be the best choice?

Thanks!
 
Joe Ess
Bartender
Posts: 9428
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
URLConnection is abstract. Most any URLConnection is actually an instance of HttpURLConnection. So that's one down.
I've had good results with both HttpClient and URLConnection. HttpClient makes it easy to manage cookies so if you have to maintain a session I'd go with it.
 
Cindy Jones
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can't we use servlet to post the request here? Do we need to use URLConnection for sending the data over a secured connection.

Thanks
Ravi
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can't we use servlet to post the request here?

You can't use a servlet to send a request. Servlet can only receive a request and send a response.
 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How foolish Am I . I haven't even read the question properly. Anyways thanks for clarification.

Thanks
Ravi
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!