A minimal HTTP server built from scratch using Java's ServerSocket and Socket classes — no external libraries needed.
Compile and run:
javac SimpleHTTPServer.java
java SimpleHTTPServerThen open your browser and go to http://localhost:8080. You'll see today's date returned as a response.
The server binds to port 8080, waits for a browser to connect, reads the incoming HTTP request, and writes back a 200 OK response with today's date. It then closes the connection and loops back to wait for the next client.
- Handles one client at a time (single-threaded)
- Always returns the same response regardless of the request
- No HTTPS support
Based on this Javarevisited tutorial.