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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:18:47+00:00 2026-05-28T20:18:47+00:00

In my application, I have to get data from 4 different urls and then

  • 0

In my application, I have to get data from 4 different urls and then after the completion of fetching data, I have to show items in a particular sequence. I am using HttoPost to send post request. I am sending 4 requests each in a different thread. When a thread get data, it increment a count. When count reaches to 4, it means that all the 4 threads have fetched data. The problem is that sometimes one of the four threads don’t respond means the defaultHttpClient.execute(post) don’t return. Due to this, my count don’t reaches 4 even it don’t throws exception and only wait dialog keeps showing. I want that after a fixed time, it must return regardless of whether it get response from server or not. Any idea?

  • 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-28T20:18:47+00:00Added an answer on May 28, 2026 at 8:18 pm

    Its not working. I am using the following class:

    public class ConnectionManager {
    
    private  ArrayList <NameValuePair> params;
    private  ArrayList <NameValuePair> headers;
    private String url;
    
    public ConnectionManager(String url) {
        this.url = url;
        params = new ArrayList<NameValuePair>();
        headers = new ArrayList<NameValuePair>();
    }
    
    public void addParam(String name, String value)
    {
        params.add(new BasicNameValuePair(name, value));
    }
    
    public void addHeader(String name, String value)
    {
        headers.add(new BasicNameValuePair(name, value));
    }
    
    public String sendRequest() throws Exception {
        String serverResponse = "";
        HttpPost httpPostRequest = new HttpPost(url);
        httpPostRequest.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE);
        //add headers
        for(int i = 0; i < headers.size(); i++) {
            StringEntity entity = new StringEntity(headers.get(i).getValue(),"UTF-8");
            httpPostRequest.setEntity(entity);
        }
    
        if(!params.isEmpty()){
            HttpEntity httpEntity = new UrlEncodedFormEntity(params,HTTP.UTF_8);
            httpPostRequest.setEntity(httpEntity);
        }
    
        serverResponse = executeRequest(httpPostRequest);
        return serverResponse;
    }
    
    private String executeRequest(HttpUriRequest request) throws Exception  {
    
        HttpParams params = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(params, 3000);
        HttpConnectionParams.setSoTimeout(params, 10000);
        DefaultHttpClient client = new DefaultHttpClient(params);
    
        HttpResponse httpResponse;
        String serverResponse = "";
        httpResponse = client.execute(request);
        HttpEntity entity = httpResponse.getEntity();
        if (entity != null) {
            InputStream instream = entity.getContent();
            serverResponse = convertStreamToString(instream);
            instream.close();
        }
        Log.d("server response", serverResponse);
        return serverResponse;
    }
    
    private String convertStreamToString(InputStream is) {
    
        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();
            }
        }
        return sb.toString();
    }
    
    • 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 in which i have to get data from .xls
I have a Php application using stream_socket_client(), to get data through tcp from a
I have a winform application that uses some referenced web services to get data.
In my application I have lots of different data types, e.g. Car, Bicycle, Person,
I have an application which uses a web service to get data. Before getting
I have this db storing sensors acquisition data, Acquisitions (acq) come from different Control
I have a Python web application (Django, specifically). I'm reading in some data from
I have an application that has different data sets depending on which company the
In my Web Application, i have a data table(Displayed from DB using PreparedStatement). Each
Now that I know C++ I want to get into desktop application that have

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.