Download the WEB4J Example Applications
There are two web4j example applications to choose from, one called Predictions, and one called Fish and Chips Club. When starting with web4j, the Predictions application is recommended, because :
- it's smaller
- it uses a single language in the user interface, so you're less likely to encounter encoding issues
- it's more suitable for learning
The example applications aren't small. Those less experienced with Servlets will greatly benefit from first going through the tutorial.
Here's a high level comparison of the two example applications :
|Predictions||Fish and Chips Club|
|Code Size||42 classes||99 classes|
|UI Language||English||English and French|
|Number of Databases||1||3|
|Database||MySQL 5||MySQL 5|
|Access Control||Per User (web style)||Per Role (intranet style)|
|reCaptcha Account||Required||Not Required|
|License||BSD Open Source||BSD Open Source|
The web4j.jar binary is included in the example applications (and in the tutorial) at this location :
The 'look' of the example apps is simple - too simple for most real applications. It's important to note that WEB4J is a Java API, and it has little to say about the appearance of your web app. That is, you control the appearance of your apps using Cascading Style Sheets - not WEB4J.
To install the example applications, please follow closely the guidelines of the Getting Started Guide.
In general, WEB4J applications can interact with any relational database. The example applications, and their documentation, use MySQL. A script is provided for the creation and population of their databases. For the example apps, you're encouraged to use MySQL if possible. If that's not possible, then you will need to do more work to get them running, by reviewing and editing all items related to the database:
- the provided script for creating and populating the database tables
- the datasource settings in the context configuration file (predictions.xml, fish.xml)
- the numerous settings in web.xml related to the database
System requirements are :
- JDK 1.5+
- Servlets 2.4+ (Tomcat 6, for example. Please note that Tomcat 6 is used for all example apps supplied by web4j.com.)
- JSP 2.0+
- MySQL 5
The javadoc (see table above) includes convenient links to source code, JSPs, and SQL statements. The source code is syntax-highlighted to make it easier to read.
The example applications are provided as both a starting point and as a guide. It's recommended, though not required, that your applications be created by starting with an example app, and then changing it gradually. If any items are undesired, then they are simply removed by deleting directories (and any links from menus). This is only possible because of the package-by-feature style recommended by WEB4J. (See the User Guide for more information.)
This approach is consistent with the following :
- destroying things is easiest of all
- next, changing something that already exists is usually easier than starting with nothing
- finally, starting with nothing usually takes the most time
In any case, the classes in the example application are always effective guides.
The Fish & Chips Club serves as an informal "reference implementation", and exercises about 95% of the WEB4J API. It includes several modules :
- a main business domain
- webmaster tools - diagnostics, logging settings, performance stats
- user preferences - changing language, changing passwords
- access control - adding users, changing roles, resetting passwords
- translation - adding and editing translations for user interface text