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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:08:43+00:00 2026-05-26T01:08:43+00:00

I am trying to read a website using the java.net package classes. The site

  • 0

I am trying to read a website using the java.net package classes. The site has content, and i see it manually in html source utilities in the browser. When I get its response code and try to view the site using java, it connects successfully but interprets the site as one without content(204 code). What is going on and is it possible to get around this to view the html automatically.

thanks for your responses:
Do you need the URL?

here is the code:

   URL hef=new URL(the website); 
   BufferedReader kj=null;
   int kjkj=((HttpURLConnection)hef.openConnection()).getResponseCode();
   System.out.println(kjkj);
    String j=((HttpURLConnection)hef.openConnection()).getResponseMessage();
   System.out.println(j);
   URLConnection g=hef.openConnection();
   g.connect();

   try{
           kj=new BufferedReader(new InputStreamReader(g.getInputStream()));


     while(kj.readLine()!=null)
     {
         String y=kj.readLine();

         System.out.println(y);
      } 
   }

    finally
    {
         if(kj!=null)
        {
            kj.close();
         }
    }


   }
  • 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-26T01:08:44+00:00Added an answer on May 26, 2026 at 1:08 am

    Suggestions:

    • Assert than when manually accessing the site (with a web browser client) you are effectively getting a 200 return code
    • Make sure that the HTTP request issued from the automated (java-based) logic is similar/identical to that of what is sent by an interactive web browser client. In particular, make sure the User-Agent is identical (some sites purposely alter their responses depending on the agent).
    • You can use a packet sniffer, maybe something like Fiddler2 to see exactly what is being sent and received to/from the server
    • I’m not sure that the java.net package is robot-aware, but that could be a factor as well (can you check if the underlying site has robot.txt files).

    Edit:
    assuming you are using the java.net package’s HttpURLConnection class, the “robot” hypothesis doesn’t apply.
    On the other hand you’ll probably want to use the connection’s setRequestProperty() method to prepare the desired HTTP header for the request (so they match these from the web browser client)
    Maybe you can post the relevant portions of your code.

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

Sidebar

Related Questions

I am trying to read data from a website. I can see the value
I have been trying to read the source of a website with the following:
I am using java.net.HttpURLConnection to connect to a website and send some data through
I have an ASP.NET website which is using a filestream to read in a
I am trying to write a C++ program to read from a website using
I'm trying to create a website in IIS using this code (from another site
I'm trying a simple app to read in the HTML of a website, and
I'm trying to extract text and HTML from a website with Scandinavian characters using
Trying to read an RSS and select information using Linq but can't seem to
I am trying to read a single file from a java.util.zip.ZipInputStream , and copy

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.