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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:15:12+00:00 2026-06-15T22:15:12+00:00

I have a Java application : -this application send a String : HttpClient httpClient

  • 0

I have a Java application :

-this application send a String :

HttpClient httpClient = new DefaultHttpClient();

    try {
        HttpPost request = new HttpPost(url);
        StringEntity params = new StringEntity(xml);
        request.addHeader("content-type", "application/x-www-form-urlencoded");
        request.setEntity(params);
        HttpResponse response = httpClient.execute(request);

        // handle response here...
        String res= response.toString();
        System.out.println("RESPONSE=>\n"+response); //where i read the response
    } catch (Exception ex) {
        // handle exception here
    } finally {
        httpClient.getConnectionManager().shutdown();
    }

I work with this String in my servlet and I just want to send a String response.

response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    out.print("TEST");

But when i read the response i just have my header:

RESPONSE=>
HTTP/1.1 200 OK [X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7), Server: GlassFish Server Open Source Edition 3.1.2.2, Content-Type: text/html;charset=UTF-8, Content-Length: 83, Date: Fri, 14 Dec 2012 17:17:07 GMT]

Someone can help me ?

  • 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-15T22:15:13+00:00Added an answer on June 15, 2026 at 10:15 pm

    You are using the wrong method to read your response date. Calling:

    String res= response.toString();
    

    Just gives you the string representation of the Response object, not the data it contains. The Apache Http Commons library has a utility class that makes it easy to read responses, called EntityUtils. Use this instead to read the entire response body. Don’t forget that you need to verify that the request actually completed successfully before doing this:

    if(response.getStatusLine().getStatusCode() == 200) {
        final String res = EntityUtils.toString(response.getEntity());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have weblogic where I can deploy this java application and database where I
In my Java application I have some copy-constructors like this public MyClass(MyClass src) {
I have this application written in java to calculate pageranks. And the application takes
I have an application which resides in ROOT. This application has a java class(in
So I have this nice spiffy MVC-architected application in Java Swing, and now I
I have an application that passes in java.util.Date. I want to check whether this
In our application, I have seen code written like this: User.java (User entity) public
How can I send string data from Java to a C++ console application under
I have Java application which sends pointer to function (callback) to some native dll
I have a Java application that run as a background service, i.e. no GUI.

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.