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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:07:19+00:00 2026-06-18T08:07:19+00:00

I am using commons HttpClient to make an http call to a Spring servlet.

  • 0

I am using commons HttpClient to make an http call to a Spring servlet. I need to add a few parameters in the query string. So I do the following:

HttpRequestBase request = new HttpGet(url);
HttpParams params = new BasicHttpParams();
params.setParameter("key1", "value1");
params.setParameter("key2", "value2");
params.setParameter("key3", "value3");
request.setParams(params);
HttpClient httpClient = new DefaultHttpClient();
httpClient.execute(request);

However when i try to read the parameter in the servlet using

((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest().getParameter("key");

it returns null. In fact the parameterMap is completely empty. When I manually append the parameters to the url before creating the HttpGet request, the parameters are available in the servlet. Same when I hit the servlet from the browser using the URL with queryString appended.

What’s the error here? In httpclient 3.x, GetMethod had a setQueryString() method to append the querystring. What’s the equivalent in 4.x?

  • 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-18T08:07:20+00:00Added an answer on June 18, 2026 at 8:07 am

    Here is how you would add query string parameters using HttpClient 4.2 and later:

    URIBuilder builder = new URIBuilder("http://example.com/");
    builder.setParameter("parts", "all").setParameter("action", "finish");
    
    HttpPost post = new HttpPost(builder.build());
    

    The resulting URI would look like:

    http://example.com/?parts=all&action=finish
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Apache's commons-httpclient for Java, what's the best way to add query parameters to
I am using apache's common httpclient library. Is it possible to make HTTP request
I'm using Spring and Hibernate. I'm uploading images using commons-fileupload-1.2.2 as follows. String itemName
So I'm using Apache Commons HTTP to make a request to a webpage. I
I'm using org.apache.commons.httpclient.HttpClient and need to setup response encoding (for some reason server returns
I found a couple of questions somewhat related to this: httpclient-request-set-attribute-question commons-httpclient-adding-query-string-parameters-to-get-post-request but I
I am trying to connect to a secure server using Apache Commons HttpClient 3.1
I am using Jakarta Commons HttpClient 3.1 writing a load test tool that needs
I'm using Apache commons HTTPClient with Apache Axis 1.5 and I'm trying to log
I am using Apache Commons HttpClient 3.1, and I found that HttpURLConnection from Sun

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.