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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:50:16+00:00 2026-05-22T17:50:16+00:00

wow , i just can’t find any working httpclient 4.1 example , to send

  • 0

wow , i just can’t find any working httpclient 4.1 example , to send post request with Not default port
but configurable port , i have this code but its dosn’t work

// lHashMapParams is with params getting form function .. 

List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
        for (String key : lHashMapParams.keySet()) {
            String val = lHashMapParams.get(key);
            params.add(new BasicNameValuePair(key,val));

}
String url = "https://foo.com";
int port = 8883;
String = "https";
UrlEncodedFormEntity query = new UrlEncodedFormEntity(params);
        HttpHost httpHost = new HttpHost(url,port,httpType); 

        HttpPost post = new HttpPost("/");
        post.setEntity(query);


        HttpResponse response_ = httpclient.execute(httpHost,post);

getting this exception :

log4j:WARN Please initialize the log4j system properly.
java.net.UnknownHostException: https://foo.com
    at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:849)
    at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1183)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1136)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1109)
    at java.net.InetAddress.getAllByName(InetAddress.java:1072)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:242)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:130)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:561)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:776)
    at com.ut.HttpClientImpl.postHttpReqest(HttpClientImpl.java:75)  

is simple words how to define port ?

  • 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-22T17:50:17+00:00Added an answer on May 22, 2026 at 5:50 pm

    You are attempting to perform a lookup of the host name https://foo.com
    and that’s the problem; the lookup should have been against foo.com. I’m not sure as to how you’ve arrived at the code in question, but it would be worth some time to take a look at the HttpClient tutorial.

    If I’m not wrong, the following code, should be sufficient:

    HttpPost httpost = new HttpPost(url); //construct the complete URL i.e. action to post to
    httpost.setEntity(entity);
    response = httpclient.execute(httpost);
    

    where url is to be constructed with the http/https schema, host name, port and the rest of the resource URI.

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

Sidebar

Related Questions

Wow, this should be so simple, but it' just not working. I need to
Wow, I just got back a huge project in C# from outsourced developers and
My work just gave me a quad core computer, and WOW build times are
Wow, it's hard to find a simple explanation to this topic. A simple many-to-many
WOW! That's a weird title, but I'm happy you're looking, cause I couldn't find
EDIT: WOW. This question is 12 years old now. As someone stated, it can
It's really simple, I just want one screen. Wow, that [shiny thing] must have
Wow...I've never seen this before. Any way to get around it? foreach( double r
I've been evaluating various smart pointer implementations (wow, there are a LOT out there)
I need to get the path to the native (rather than the WOW) program

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.