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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:40:37+00:00 2026-05-30T21:40:37+00:00

I am working with apache http client (v4) in a java web app, and

  • 0

I am working with apache http client (v4) in a java web app, and I am stuck in the following cases, for which I require simple usage examples–

(1) How to use Cookies with Apache HTTP client, different options available for usage of cookies

(2) Extracting charset, mimetype, response headers (as KeyValuePair) and budy (as byte[]) when the response is available in HTTPResponse object.

  • 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-30T21:40:38+00:00Added an answer on May 30, 2026 at 9:40 pm

    1)AS for cookies,see that exapmle:

    httpcomponents-client-4.1.3\examples\org\apache\http\examples\client\ClientCustomContext.java

    main code:

    HttpClient httpclient = new DefaultHttpClient();
            try {
                // Create a local instance of cookie store
                CookieStore cookieStore = new BasicCookieStore();
    
                // Create local HTTP context
                HttpContext localContext = new BasicHttpContext();
                // Bind custom cookie store to the local context
                localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
    
                HttpGet httpget = new HttpGet("http://www.google.com/");
    
                System.out.println("executing request " + httpget.getURI());
    
                // Pass local context as a parameter
                HttpResponse response = httpclient.execute(httpget, localContext);
            } finally {
                // When HttpClient instance is no longer needed,
                // shut down the connection manager to ensure
                // immediate deallocation of all system resources
                httpclient.getConnectionManager().shutdown();
            }
    

    2)You can get all you need from response and:

    HttpEntity entity = response.getEntity();
    entity.getContent()
    

    Just read the examples in:
    httpcomponents-client-4.1.3\examples\org\apache\http\examples\client
    of httpcomponents-client-4.1.3-bin.zip which is downloaded from its website.

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

Sidebar

Related Questions

I'm working on a school project, which requires JAVA to send a series of
I'm working in Java with Apache's HTTPClient and trying to connect to graph.facebook.com. I'm
I'm connecting to a remote server with apache http client. the remote server sends
Simple Concept that is not working: I'm trying to connect to the web and
I'm using MyEclipse to develop a really simple Java Struts project. Everything was working
I'm working with Apache mod_dav compiled on my own server. My client is built-from-scratch
I have a crawler Java application which is supposed to connect to some HTTP
I'm working on an Apache Wicket project in Eclipse with Maven2 -- my SCM
I'm working with the Apache Thrift tool and i'm throwing some Exceptions from the
I've been working with the Apache Mahout machine learning libaries in my free time

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.