TinyWeb in Java
The Java version of TinyWeb is a basic MVC web framework written in a classic object-oriented style. To handle requests we use a Controller implemented using the Template method, which we cover in detail in Pattern 6, Replacing Template Method. Views are implemented using the Strategy pattern, covered in Pattern 7, Replacing Strategy.
Our framework is built around core pieces of data objects, HttpRequest and HttpResponse. We want these to be immutable and easy to work with, so we are going to build them using the Builder pattern discussed in Pattern 4, Replacing Builder for Immutable Object. Builder is a standard way of getting immutable objects in Java.
Finally, we’ve got request filters that run before a request is ...