This project is a Java based multithreaded TCP web server that implements responses for HTTP 200, 301, and 404 codes. It was made using Java 8 and runs by default on port 6789 of localhost.
This project is licensed under the terms of the MIT license.
-
Compiling the Program
- Open console and type
javac src/WebServer.java
- Open console and type
-
Running the Program
- Type
java src/WebServerto run the program
- Type
-
Testing HTTP 200 OK:
- In your browser of choice type
localhost:6789/index.htmlinto the address bar. A webpage should appeart with the text "Hello, World! This is a simple HTML document." and an image of a cityscape underneath.
- In your browser of choice type
-
Testing HTTP 404 Not Found:
- In your browser of choice type
localhost:6789/whateverinto the address bar. An error page should load that says "404 Error: Page Not Found" in big bold letters.
- In your browser of choice type
-
Testing HTTP 301 Moved Permanently (Redirect):
- In your browser of choice type
localhost:6789/index,localhost:6789/,localhost:6789, orlocalhost:6789/index.htminto the address bar. Typing any of the above will redirect you to the index.html page with the Hello message and image.
- In your browser of choice type