Run gradle build
.\gradlew.bat clean build
This will generate jar file under build\libs directory
Run the Java jar file
java -jar build\libs\webserver-1.0-SNAPSHOT.jar
And the server load prints
Starting app on directory: C:\Users\[User]\Projects\webserver
Starts web server on port: 80
Open web browser and load localhost
http://localhost
it will print the listing of application run directory e.g. C:\Users[User]\Projects\webserver.
I prepared test directory public/ which contains index.html. You can change into this directory before running the server to test how the webserver responds with html content by clicking index.html link when directory listing is loaded.
JDK/JRE: Adopt OpenJDK v11 (OpenJ9)
Due to limitation of using only standard Java SE 8:
- Use combination of ServerSocket and BufferedReader to process incoming request to port 80.
- Use combination of BufferedWriter and StringBuilder to generate response.
- Build own HTTPStatus class using Map, currently only HTTP status 200, 404 and 500 included.
- Break main method to process request separately.
- Add configuration for port, serving directory.
- Complete HTTP error status.
- Add unit tests.
- Use Threading and Non blocking IO.