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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:57:17+00:00 2026-06-08T01:57:17+00:00

In my application, I am trying to hit a URL which I do using

  • 0

In my application, I am trying to hit a URL which I do using the following code

  try {
    url = new URL(serverURL);

    httpURLConnection = (HttpURLConnection) url.openConnection();

    int timeout = 30000;
    httpURLConnection.setConnectTimeout(timeout);
    httpURLConnection.setReadTimeout(timeout);

    httpURLConnection.connect();

    String httpResponseMessage = httpURLConnection.getResponseMessage();
    responseCode = httpURLConnection.getResponseCode();

    Log.i(LOG_TAG,"Response code "+responseCode);

    } catch (Exception e) {
    e.printStackTrace();
    }

The (confidential) URL when opened through browser (on computer as well as on phone), works perfectly and the response is as expected. But when I hit the same URL via the above piece of code, it gives me response code 404 (NOT FOUND). Can anybody tell me what the issue can be?
(Sorry, can not post the URL since is highly confidential.)

  • 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-08T01:57:19+00:00Added an answer on June 8, 2026 at 1:57 am

    Problem solved 🙂

          try {
    
                url = new URL(serverURL);
    
                Log.i(LOG_TAG, url+"");
                HttpGet method= new HttpGet(new URI(serverURL));
                HttpClient client = new DefaultHttpClient();
                HttpGet request = new HttpGet();
                request.setURI(new URI(serverURL));
                HttpResponse response = client.execute(method);
                responseCode = response.getStatusLine().getStatusCode();
    
                Log.i(LOG_TAG,"Response code response "+response);
                Log.i(LOG_TAG,"Response responseCode "+responseCode);
            } catch (Exception e) {
                e.printStackTrace();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an iPhone application and trying to create a savePDFFile method by using
I am trying to restart an application in WPF. I tried the following: Process.Start(Application.ExecutablePath);
IOException Error in getContentFromUrl method: java.io.FileNotFoundEx We are trying to hit a URL: http://somewebsite.com/somefolder/dosomething?zip=75070&servCat=1
I'm trying to debug my Java application in Eclipse however when I hit a
I am using tomcat as my webserver. I hit some url in IE and
I am trying to distribute my Enterprise Application using the method described in the
I hit this error while my web application was trying to execute a SELECT
I have a Spring MVC application trying to use a rich domain model, with
My application is trying to do a distributed transaction on 2 databases on a
in my application i trying to implement the cache (ouput) but it is not

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.