This tutorial gives step-by-step instructions how to build web application using Jodd. Along it also provides some best-practices using Jodd frameworks.
This is just one way of how to build web applications with Jodd; what matters here is the concept and not the concrete values, structures or configuration used in example.
Attention: this example is not trivial one since it covers many different topics of web development. It would be good if you have some basic information about Jodd components before proceeding with the example. The subject of the example is how to configure and prepare infrastructure for development, so don't be mislead with the amount of presented information - working with Jodd is simple, but not simpler.
Here goes a short overview of each step.
As for any web application, we need servlet container installed, such as Apache Tomcat. We also assume that database server of choice is already installed (e.g. MySql or H2 or Oracle XE or ...) and ready to use.
For this example, we need just following jars:
jodd-*.jar and jodd-wot-*.jar (< 800K)asm-3.2.jar (< 40K)slf4j-api-1.5.8 and slf4j-simple-1.5.8.jar (30K)servlets-2.4.jar (140K), for compilationNext, lets choose the top architecture of our web application: we will have three separated layers: view, services and data. Service layer is not coupled with the presentation and may be executed (and tested) from the command line, if needed. Transactions are therefore declared on service layer. Data layer is written following DAO pattern. Presentation view is just preparing and calling services and parsing results back. All-in-all, nothing special, just a common three-layer web application.
Although presentation layer is usually not the first thing to develop, we start this example with Madvoc.
After adding the basic presentation skeleton, we can continue with the real stuff: business layer. We will organize business components using Petite.
It's time for data! Let's combine the power and simplicity in one, using Db and DbOrm.
Wrap services with transactions handling code using Proxetta.
Control page access with Madvoc interceptors.
Different architecture type, just for fun... or real!?