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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:04:08+00:00 2026-05-25T21:04:08+00:00

So I have an assignment where I have to make a HTTP Server with

  • 0

So I have an assignment where I have to make a HTTP Server with chosen programming language. No big deal. I have encountered a problem that I cant seem to figure out. Every time I load the homepage that and the server response, it prints out about 5 times. Cant figure out why. Okay so what I mean:

Code Snippets:

while(true){
    connectedClient = listenSocket.accept();

    inFromClient = new BufferedReader( new InputStreamReader( connectedClient.getInputStream()));

    outToClient = new DataOutputStream(connectedClient.getOutputStream());

    String requestString = inFromClient.readLine();
    String headerLine = requestString;

    StringTokenizer tokenizer = new StringTokenizer(headerLine);
    String httpMethod = tokenizer.nextToken();
    String httpQueryString = tokenizer.nextToken();

    requestString = inFromClient.readLine();
    if (httpMethod.equals("GET")) {
        if (httpQueryString.equals("/Home")) {
        // The default home page status code 200
        dateHeader();
        connectionCloseHeader();    
    }
//other code not related
}

And this is my date header method:

public static void dateHeader() throws Exception{
    DateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
    Date date = new Date();
    System.out.println("Date: " + dateFormat.format(date));
}

My output to the terminal will be 5 printouts of the date. I made sure that the connection and such was closed but same thing happens. Anyone have an idea why this is happening? Thanks.

EDIT

Seems that when using Chrome I get the one print out no problem. I was testing with Opera and that was giving me the 5 printouts. Perhaps something with the way the browsers work is causing the issue. Ill just use chrome now for it though.

  • 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-25T21:04:09+00:00Added an answer on May 25, 2026 at 9:04 pm

    I can’t account for five different invocations right off, but if you’re using a typical browser to hit this HTTP server, you’ll immediately see two requests: one for the resource itself and one for a favicon.ico. Somewhere in your request handler, you should read in and print out the entire request. Then you can see exactly what all the requests are for.

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

Sidebar

Related Questions

For an assignment in college, we have to make a script in Perl that
I have this assignment to prove that this problem: Finite alphabet £, two strings
i got an assignment to make something similar to http://typewith.me .The problem i am
I've been trying to figure out this problem. I have an assignment to make
For my university assignment I have to make a networkable version of pacman. I
I have an assignment in a language-independent class, and part of it is using
So I'm working on a networking assignment to produce a basic HTTP/1.0 web server
I have this assignment due that requires the usage of FLTK. The code is
I have an assignment from my programming class, which is very poorly worded... The
I have an assignment, and it has (amongst others) two demands: make an installer

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.