This class extends Exception and overrides the getMessage(String) Methode, which is responsibe for example for the Error 404 Not Found message.
This class is a static Map of file type to mimetype mappings. It can be extended easily.
This class extends the Thread class and can and is run as a thread therefore. For every request occurring in the Server class, a new RequestWorker is created which handles the user request. Note that this class is kept ultra simple. It converts the path part of the HTTP request to a file path and servers this file back to the user.
This class also inherits from the Thread class and is run as such. It creates a ServerSocket and creates a RequestWorker thread for each request.
This is an Enum containing the HTTP codes and its corresponding error messages.
When started, the server serves the content in the root folder. Open your browser and type http://localhost:8080. When everything is okay, you see the welcome website.
Download the source code here: SimpleJavaWebServer.