Skip to content

tingjj/COMP5311_Project

Repository files navigation

COMP5311 Project

This is a simple multi-threaded web server built using Java.

Project Directory Structure

The project directory contains the following files:

  1. ClientHandler.java

    • This file contains the ClientHandler class which implements the Runnable interface. It handles client requests by reading the request line, parsing headers, and generating appropriate responses. It also logs the requests using the Logger class.
  2. Logger.java

    • This file contains the Logger class which provides a static method logRequest to log client requests to a file named server_log.txt. It logs the client's IP address, the requested file name, and the response type along with a timestamp.
  3. www/index.html

    • This file is the default HTML file served by the web server. It contains a simple HTML structure with a title and a heading for the COMP5311 Project.
  4. WebServer.java

    • This file contains the WebServer class which initializes the server, binds it to a specified port, and listens for incoming client connections. It creates a new ClientHandler thread for each connection to handle the client's request.

Compilation and Execution

To compile and run the web server, follow these steps:

  1. Open a terminal and navigate to the project directory.

  2. Compile all the Java files using the following command:

    javac *.java
    
  3. Start the web server by running the WebServer class using the following command:

    java WebServer
    
  4. Open a web browser and navigate to http://127.0.0.1:8080 to access the default HTML file (www/index.html) served by the web server.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published