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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:55:17+00:00 2026-05-27T07:55:17+00:00

I am currently getting to grips with new HttpClient libraries to come up with

  • 0

I am currently getting to grips with new HttpClient libraries to come up with a basic class to return the html/css/etc. of requested URL. Using the example taken from here

You can see the example below:

package test;

import org.apache.http.client.ResponseHandler;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

public class Test {

    public final static void main(String[] args) throws Exception {

        HttpClient httpclient = new DefaultHttpClient();
        try {
            HttpGet httpget = new HttpGet("http://www.cwjobs.co.uk/");
            System.out.println("executing request " + httpget.getURI());

            // Create a response handler
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String responseBody = httpclient.execute(httpget, responseHandler);

            System.out.println(responseBody);
        } finally {
            httpclient.getConnectionManager().shutdown();
        }
    }
}

The issue I am having is that if I was to set the URL I want to request to something like http://www.google.com then it prints out the response I need. However, when I use a URL such as http://www.cwjobs.co.uk (used merely as an example) it freezes on the execute method.

I am fairly new to Java and I understand the basics of HTTP so I would love to know if:
– Although I have used a basic example I have done it wrong by either missing something that needs to be added to access that specific URL
– It is not possible to get the response I want from that specific URL due to environment setup on the Server side.
– Any extra literature or links you can recommend for me to look over outside of the Apache.org site

Thanks,
Mark

  • 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-27T07:55:17+00:00Added an answer on May 27, 2026 at 7:55 am

    You have to set the timeout in DefaultHttpClient for the connection. See: http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/CoreConnectionPNames.html?is-external=true#SO_TIMEOUT

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

Sidebar

Related Questions

new to Ruby so I'm still getting to grips with some of the Rails
I'm currently getting a 500 error (apparently) on a url of mine, even though
Im fairly new to andorid and getting to grips with the UI elements. I
I'm getting to grips with WF4, and am currently experimenting with a proof of
I'm getting to grips with RPC in Windows and I've got a basic client/server
I am currently getting this error: System.Data.SqlClient.SqlException: New transaction is not allowed because there
I'm currently getting to grips with Android, playing around with the Lunar Lander sample.
I'm new and this might be a simple fix. I am currently getting the
I am currently getting first day Of this week and last week values with
I am currently getting images from the 'Documents' directory (using -imageWithContentsOfFile:) with no problems

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.