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

  • Home
  • SEARCH
  • 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 861169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:56:08+00:00 2026-05-15T08:56:08+00:00

I use apache commons http client to send data via post every second, is

  • 0

I use apache commons http client to send data via post every second, is there a way to make the following code more efficient? I know http is stateless, but is there anything I can do to improve since the base url is always the same in this case(only the parameter value change.

private void sendData(String s){ 
      try
         {
              HttpClient client = getHttpClient();


              HttpPost method = new HttpPost("http://192.168.1.100:8080/myapp");
              System.err.println("send to server "+s);
              List formparams = new ArrayList();
              formparams.add(new BasicNameValuePair("packet", s));

              UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
              method.setEntity(entity);

              HttpResponse resp=client.execute(method);
              String res = EntityUtils.toString(resp.getEntity());
              System.out.println(res);

         }
         catch (Exception e)
         {
              e.printStackTrace();

         }
    }
 private HttpClient getHttpClient() {
  if(httpClient==null){
   httpClient = new DefaultHttpClient();
  }
  return httpClient;
 }
  • 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-15T08:56:09+00:00Added an answer on May 15, 2026 at 8:56 am

    Use a multi-threaded connection manager,

    http://hc.apache.org/httpclient-3.x/threading.html#MultiThreadedHttpConnectionManager

    This will improve the keep-alive and improve the chance that your connection is ready every second so you don’t have to reestablish the TCP connection.

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

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use the standard C library directly. fopen then… May 16, 2026 at 12:13 pm
  • Editorial Team
    Editorial Team added an answer Important update: as of iOS 4.2, Apple have fixed the… May 16, 2026 at 12:13 pm
  • Editorial Team
    Editorial Team added an answer If someone sits on it long enough for the session… May 16, 2026 at 12:13 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

In the days of version 3.x of Apache Commons HttpClient, making a multipart/form-data POST
I use Apache Commons FileUpload to receive uploaded files in a Servlet, as described
I'm using Apache Common library for HTTP operations: HttpClient client = getClient(); PutMethod put
I'm trying to parse the title from the following webpage: http://kid37.blogger.de/stories/1670573/ When I use
There are many how-to's for people who want to use Rails with Apache and
I have a written a client side HTTP cache and I need to store
I've been using the org.apache.commons.mail.HtmlEmail class, from apache commons-mail, for some time. Eventually, some
Is there any built in library that I can use for calculating median in
I'm on Windows Vista Home Premium 64 bit OS. I use Apache Friends XAMPP
QUESTION : how can I use a different encoding (charset and transfer) with axis?

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.