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 8168269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:28:00+00:00 2026-06-06T20:28:00+00:00

I am not able to retrieve the data from the server. I am not

  • 0

I am not able to retrieve the data from the server. I am not sure where i have gone wrong in the code..When i run the application, the data from the server is not displayed on the emulator.. The code is given below

private void postData1(){


HttpClient httpclient = new DefaultHttpClient();

HttpPost httppost = new HttpPost(
        "http://www.xxxxx.co.uk/NottTest/post.php");

JSONObject json = new JSONObject();

try {

    // JSON data:

    try {
        json.put("name", "Fahmi Rahman");
    } catch (JSONException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    json.put("position", "sysdev");

    JSONArray postjson = new JSONArray();

    postjson.put(json);

    // Post the data:

    httppost.setHeader("json", json.toString());

    httppost.getParams().setParameter("jsonpost", postjson);

    // Execute HTTP Post Request

    System.out.print(json);

    HttpResponse response = httpclient.execute(httppost);
    tv.setText("Hiii");

    // for JSON:

    if (response != null)

    {
        Log.i("Json","respose");
        System.out.print("loooooooooool");


        InputStream is = response.getEntity().getContent();

        BufferedReader reader = new BufferedReader(
                new InputStreamReader(is));

        StringBuilder sb = new StringBuilder();

        String line = null;

        try {

            while ((line = reader.readLine()) != null) {

                sb.append(line + "\n");

            }

        } catch (IOException e) {

            e.printStackTrace();

        } finally {

            try {

                is.close();

            } catch (IOException e) {

                e.printStackTrace();

            }

        }

        text = sb.toString();

    }

    else{
        tv.setText("no respose");
        Log.i("Noting","happended");
    }

    //tv.setText(text);

} catch (ClientProtocolException e) {

    Log.i("Error","Prtocol");


} catch (IOException e) {

    Log.i("Error","IO");

} catch (JSONException e) {
    Log.i("Error","JOSON");
}

}

  • 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-06-06T20:28:02+00:00Added an answer on June 6, 2026 at 8:28 pm

    i think the error is in

    try {
            json.put("name", "Fahmi Rahman");
        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    
        json.put("position", "sysdev");
    
        JSONArray postjson = new JSONArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an application where it should get data from my server with
I am able to retrieve data from a website(Nestoria) and store into my PostGIS
I have a web-app-database 3 tier server setup. Web requests data from app, and
Not able to download artifacts from central maven repository. <mirrors> <!-- mirror | Specifies
Not able to store all binary data values into sqlite3 table using QT. For
I am not able to build my application via Ant build.xml file when I
The application that I have in the works uses GPS data to mark files
I cannot retrieve multiple files in my php code from $_FILES. Here is the
I've got a WebService that is used by another application to retrieve data. We
I made a SMTP server using smtpd module in python. I have been able

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.