Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7536383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:33:33+00:00 2026-05-30T06:33:33+00:00

I am using URLConnection Object to send data from my android client to server.

  • 0

I am using URLConnection Object to send data from my android client to server.

URL url = new URL("http://10.0.2.2:8080/hello");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
ObjectOutputStream out=new ObjectOutputStream(connection.getOutputStream());
String s="check"+","+susername;
out.writeObject(s);
out.flush();
out.close();

But I have seen many android programs sending data using httppost in the following way.

HttpClient client=new DefaultHttpClient();
HttpPost httpPost=new HttpPost(LOGIN_ADDRESS);
List pairs=new  ArrayList();
String strUsername=username.getText().toString();
String strPassword=password.getText().toString();
pairs.add(new BasicNameValuePair("username", strUsername));
pairs.add(new BasicNameValuePair("password", strPassword));
httpPost.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse response= client.execute(httpPost);

please explain the differnce between the two. How would you receive the data in the later case in a servlet. please give a brief explanation on this HttpPost. In the internet all I find is code. pls give a step by step explanation on HttpPost and its methods and how should the data be received in the servlet. Links will do fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:33:35+00:00Added an answer on May 30, 2026 at 6:33 am

    This blog post does a pretty good job of explaining the difference between the two of them (well actually HttpURLConnection, but that’s just a subclass of URLConnection). Some highlights from the article are:

    • HttpURLConnection easily allows gzip encoding
    • HttpURLConnection can allow for easy caching of results
    • HttpURLConnection is newer and being actively developed on so it’s only going to get faster and better
    • HttpURLConnection has some annoying bugs on foryo and pre-froyo platforms
    • HttpClient is tried and true. It’s been around for a long time and it works
    • HttpClient is pretty much not being developed on because it’s so old and the API is completely locked down. There isn’t much more the android developers can do in terms of making it better.

    While the end of the article recommends use of HttpURLConnection on all platforms above froyo, I personally like using HttpClient no matter what. It’s just easier to use for me and makes more sense. But if you’re already using HttpURLConnection, you should totally keep using it. It’s going to be receiving lot’s of love from the android developers from here-on-out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using HTTP connection to share data with my JSON server. I use URLs
My client first creates a url object with the url of the server (containing
I'm using this code for downloading image from server: public Bitmap getBitmap(String path){ URL
I am trying to authenticate to a server's secure URL using java.net.urlconnection - based
I have an Applet which is loading images over a http connection using URLConnection.
Is it possible to send a Http header via a URL connection in java?
I need to connect to the middleware server using java URL and URLConnection classes
I am using simple urlconnection like this: url = URL+getClient&uid=+cl_id; URL url = new
I have a URLConnection, that access a web page. URL url = new URL(https://domain);
I'm using socket to establish a streaming connection with server. By creating a socket,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.