title: HTTP Server System.out problem
body: <p>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:</p>
  
  <p>Code Snippets:</p>
  
  <pre><code>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
  }
  </code></pre>
  
  <p>And this is my date header method:</p>
  
  <pre><code>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));
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>EDIT</p>
  
  <p>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.</p>