Fish and Chips Club - WEB4J Example Application.
This is an example application, authored by John O'Hanley.
It demonstrates using WEB4J to build
a typical Java web application : a person using a browser to interact with
a relational database.
The problem domain is a Fish and Chips Club, where a group of friends meet
regularly for lunch at various local restaurants, to have Fish and Chips for lunch.
To run this application, please see the Getting Started Guide.
Features
Miscellaneous
Version History
Features
Features specific to the Fish and Chips Club include :
- edit club members
- edit local restaurants
- edit ratings of each restaurant
- adding new lunches (a given restaurant on a given day)
- members can RSVP for each upcoming lunch
- simple discussion board
- some simple reports
- a simple search page
Other features are more generic, and may be used as templates or guidelines in development
of your own applications:
- security/access module for administering users
- webmaster module for monitoring performance, and sending trouble tickets
- translation module demonstrates mechanisms for multilingual sites (using English and French)
- user preferences and password control module
Miscellaneous
Note that package-by-feature is used.
This is the recommended style, though it is not required.
(If you have never used package-by-feature, you are encouraged
to try it: those who do try it rarely return to the package-by-layer style.)
The hirondelle.web4j.config package is special, and is reserved by WEB4J
for the exclusive use of the application programmer. See
{@link hirondelle.web4j.BuildImpl} in the WEB4J javadoc for more information.
Version History
Version Number Convention
The first three parts of the version number of the Fish and Chips Club is synchronized with the version number
of the corresponding web4j.jar version number with which it was built.
For example,
- version 3.0.0.1 was built with version 3.0.0 of web4j.jar
- version 3.1.0.0 was built with version 3.1.0 of web4j.jar
- and so on...
4.10.0.0 - published October 19, 2013
Updated the version of web4j.jar. This is the first version to use JDK 1.6.
The fileupload feature now stores the uploaded file (using its InputStream) in the database, and lets you serve the bytes from the
database. Before, this feature only saved the bytes to the server's file system.
This exercises the new support for InputStream as a building-block type.
4.9.0.0 - published October 5, 2013
Updated the version of web4j.jar.
4.8.0.0 - published June 9, 2012
Updated the version of web4j.jar.
4.7.1.0 - published September 24, 2011
Updated the version of web4j.jar. Minor bug fix.
4.7.0.0 - published September 17, 2011
Updated the version of web4j.jar.
Two config items that force creation of threads have been removed from web.xml:
- BadResponseDetector
- EmailInSeparateThread
The displayMessages.tag has been altered, to simply remove session-scope messages after they have been
displayed.
4.6.2.0 - published July 9, 2011
The only change is to the version of web4j.jar.
4.6.1.0 - published May 15, 2011
The only change is to the version of web4j.jar.
4.6.0.0 - published March 1, 2011
Includes an implemention for the new LoginTasks interface.
The old Servlet Filter, which used to react to user login, has been removed.
New settings in web.xml, for the improved implementation of EmailerImpl.
4.5.1.0 - published January 29, 2011
Encoding issues have been fixed.
- JSP files have all been saved with UTF-8 encoding.
- uses version 4.5.1 of web4j.jar, which includes a fix for an encoding problem in CsrfFilter.
- script for creating the database now explicitly states utf8 encoding
- web.xml now uses a prelude setting for JSPs
- tag files now include TagHeader.jspf
- JspHeader.jspf and TagHeader.jspf appear in WEB-INF, not in the web app's root directory
4.5.0.0 - published April 17, 2010
Fixed :
- web4j.tld now has description elements appearing first.
- RestoSearchCriteria.getStartsWith() now returns SafeText, not String.
- some JSPs were referencing items which, if a translation was missing, lead to errors.
Converted some String objects to Id or SafeText.
The AllowStringAsBuildingBlock setting in web.xml has been switched on.
Since this app is an informal reference implementation, it's best to allow this, in order to exercise more code.
4.5.1.0 - published January 29, 2011
Uses a fix in web4j.jar regarding encoding. The CsrfFilter was incorrectly coercing encoding to 8859-1.
As well, ensure the app correctly supports UTF-8.
Re-save JSP's and tag files as UTF-8, change database script to explicitly state the encoding, define a prelude JSP in web.xml.
4.4.0.0 - published January 30, 2010
This version now uses DateTime, although in a small way.
(The Predictions app makes far more use of DateTime.)
The ShowDiagnostics class now uses DateTime instead of java.util.Date.
Fixed User.java, which had a NullPointerException in its validateState method.
The Discussion feature's JSP now renders a date using a fixed format, instead of one sensitive to Locale. This fixes a problem
seen when the translation of the format may be missing (which happens if the database script fails due to encoding issues.)
4.3.0.0 - published September 7, 2009
FakeServletContext has added getContextPath (which is likely to be added in the Servlet 3.0 Specification)
RestoSearchCriteria - validation message text in 2 cases (min/max price) had no '_1_' placeholder, and was failing at runtime.
4.2.0.0 - published March 19, 2009
The Member
feature now demonstrates an easier way of deleting N items at a time,
instead of 1 at a time.
4.1.0.0 - published February 21, 2009
There are no updates to this application for this release of web4j.
If desired, however, you can now add an implementation of TimeSource as your
fake system clock.
See BuildImpl for related configuration information.
4.0.0.0 - published December 21, 2008
This version is the first to use the web4j.jar having no time-limit on its operation.
The distinction between the Trial Version and the Full Version no longer exists.
The following features, formerly available only in the Full Version,
are now always available :
- upon startup, identifiers in .sql files are matched one-to-one with declared public static final SqlId fields.
Any mismatches cause an exception, and your app will not proceed. This protects you, since it changes RuntimeExceptions into startup-time exceptions, and catches trivial typing errors as soon as possible.
- upon startup, SQL statement syntax can be verified by attempting pre-compilation. This is not supported by all JDBC drivers.
- upon startup, your Model Objects are scanned for possible Cross-Site Scripting vulnerabilities, where String is used instead of SafeText.
If an issue is found, it is logged as a WARNING.
- the PerformanceMonitor filter can be configured to issue a periodic 'ping' to a fixed URL.
If a problem is detected, or if the response is too slow, a TroubleTicket email is issued.
3.10.0.0 - published September 20, 2008
- new setting in web.xml called DecimalStyle, which configures the new Decimal class
- Resto and Search features now use the Decimal class instead of BigDecimal
3.9.0.0 - published August 30, 2008
- ConvertParamErrorImpl updated for SafeText.
- web4j.tld updated for a new function, w:ampersand.
- web.xml is now configured to not allow String as a building block class.
SafeText is used instead. The intent is to protect against Cross-Site Scripting attacks.
- remove a number of extraneous .tld files from /WEB-INF/tlds/ directory.
- ensure .jsp and .html files don't create extraneous sessions.
- LogoffAction now immediately deletes the session cookie.
In addition, its ResponsePage had a misleading name, which is now changed from FORWARD to REDIRECT.
- The reverse lookup methods in CodeTable, CodeTableUtil have been removed, since they are not called.
- Search feature now uses SafeText, not String.
- Translation module no longer needs to use w:safe, since referencing SafeText already.
- add guidance for deployment to Jetty6 instead of Tomcat. See /WEB-INF/jetty/.
Jetty supports JDBC realms, but its convention for table structure differs from that of Tomcat.
In this case, a simple properties file is used instead of a JDBC Realm, just to avoid changing the table structure.
There is a NullPointerException in a server class. Occurs in the Diagnostics page of the webmaster module.
When all items in application scope are referenced, a NullPointerException is thrown by a server class's toString method.
This is an error on the server, not in web4j.
3.8.0.1 - published July 21, 2008
- web4j.tld updated to refer to JSP 2.0, not 1.2.
- TestTags.jsp included to test operation of custom tags.
- added jsp-config to web.xml.
- added /WEB-INF/geronimo-web.xml. This is a "deployment plan" file specific to WebSphere Community Edition. It's provided as an example.
- replaced package.html files with package-info.java files, since this is a more effective style.
3.8.0.0 - published June 7, 2008
Small update, mostly regarding unit testing :
- hirondelle.fish.test.doubles package added, containing a number of
test doubles.
- ConnectionSrc made non-final, to allow for a test-only version.
- TESTAll extended.
- TESTVisit improved.
For more information on unit testing, please see the User Guide.
3.7.0.1 - published May 20, 2008
Uses web4j.jar version 3.7.0
Small update to documentation :
- fix Getting Started Guide - the Tomcat directory for placing jars was incorrect.
- change some references to port 8081 to the more typical 8080.
- update README and and build.xml with minor edits.
3.7.0.0 - published May 12, 2008
Uses web4j.jar version 3.7.0
Small update :
- add action to exercise serving a binary file (in this case, a simple .rtf file).
See ServeBinaryAction and ResponsePage.withBinaryData().
- added Tomcat config file /WEB-INF/tomcat/fish.xml, which holds the Tomcat context information.
This file merely needs to be copied to TOMCAT_HOME/Catalina/localhost/, and then configured.
This is preferred over editing the server.xml file - it's less error prone,
and it allows a change of the context to be pulled in with a restart of the application, instead of the entire server.
3.6.1.1 - published April 13, 2008
Uses web4j.jar version 3.6.1
Small update (backwards compatible):
- BaseTextAction - fix the name of the field containing the explicit URI mapping.
- Getting Started Guide - a few small fixes and improvements.
3.6.1.0 - published April 8, 2008
Uses web4j.jar version 3.6.1
Small update :
- add a simple page to exercise and explore encoding issues (see the exercise module)
- FileUploadWrapper - fix getParameterMap(), whose return value did not
have the correct type for map values
3.6.0.0 - published March 11, 2008
Uses web4j.jar version 3.6.0
Small update :
- build.xml - added target for generating javadoc, with links to source code, JSPs, and .sql files.
The links to JSP files and .sql files are implemented as Taglet classes, defined in the WEB4J Development Tools
(available only with the Full Version of WEB4J).
- added module to exercise items that are not exercised elsewhere.
- exercise multi-valued parameters.
- exercise file uploads.
- add a fine-grained security constraint.
- use several action extensions in addition to '.do'. This helps implement fine-grained security constraints.
- Error.jsp replaced with Error.html.
When using response wrappers, there was sometimes an error if a JSP is used, whereby getOuptputStream()
was being called twice (which is not allowed).
3.5.0.0 - published February 16, 2008
Uses web4j.jar version 3.5.0
Small update :
- Much improved handling of login errors. Login error-page now simply redisplays the login page,
with an informative message.
- Some Cross-Site Scripting vulnerabilities detected and removed. (These were
found using the new validation performed by Controller upon startup).
- RestoSearchCriteria - getXXX methods changed to package-private.
Interesting variation on Model Object : no need to use SafeText, since data
never rendered in JSP.
- The StartupTasks implementation now does version checking between
Fish & Chips Club and web4j.jar. If an incompatibility is detected, it is logged at
SEVERE level.
3.4.0.0 - published January 22, 2008
Uses web4j.jar version 3.4.0
Small update :
- Added WelcomeFileController - improves behavior for home page requests.
- Changed Logoff.jsp - now includes link to the home page.
- Fixed sorting issues - replaced use of obsolete <w:sort> tag in markup with
DynamicCriteria class in code.
3.3.1.0 - published January 15, 2008
Uses web4j.jar version 3.3.1
Small update :
- FIX - showFocus.tag file amended. Boolean test failed when a
FIELDSET tag used in the form, since the .type property for FIELDSET is null.
- FIX - NullPointerException in TranslatorImpl occured
if database was down upon startup.
3.3.0.0 - published December 19, 2007
Uses web4j.jar version 3.3.0
Small update :
- Change - ConnectionSrc no longer uses hard coded connection strings. Instead, it uses items configured in web.xml.
- Change - amend implementation of Startup, to allow reading of web.xml config in a step separate from the main tasks.
- Change - Conventional Names : view.jsp, statements.sql are now used for many views and .sql files.
Conventional names for Actions, Models, and DAOs are not recommended, since the display of such items in javadoc would not be clear.
- Change - Comment, Rating features : Some short DAOs have been removed, and their methods placed directly into the calling Action.
- Change - many Model Objects now use the new Check.range(min, max) method to validate state. This improves legibility nicely.
- Fix - for a number of JSPs in the web app root (Logoff.jsp, etc.), the reference to the app's
character encoding was incorrect.
- Fix - Next Future Visit - an occasional off-by-one error for some dates, caused by time zone issues.
- Fix - web.xml had an incorrect example value for a TimeZone - 'Canada/Montreal' should be 'America/Montreal'.
- Add - Diagnostics page - added host name, and consolidated some server-related items.
- Clarify/Fix - Help mechanism works only for GET requests. If the request is a failed POST, then the Help menu item is not displayed.
3.2.0.1 - published Nov 17, 2007
Uses web4j.jar version 3.2.0
Small update :
- Fix UserAction.java - NullPointerException occured for empty user input
- Fix Database load - for Translation table, replace logo.png with logo.gif
- Fix RsvpShow.jsp - the display of the date now uses <w:showDate>
instead of <fmt:formatDate>. Was causing off-by-one errors when JRE time zone did
not match the application's default time zone.
- footer.tag - again, the display of the date now uses <w:showDate>
instead of <fmt:formatDate>
- Preferences Template.jsp - add "back links" to the various modules.
Use <w:show> tag to toggle appearance of links according to role of logged-in user.
3.2.0.0 - published Nov 15, 2007
Uses web4j.jar version 3.2.0
Small update :
- Diagnostics page now shows the value of the HTTP charset header sent in the response
3.1.0.2 - published Nov 3, 2007
Uses web4j.jar version 3.1.0
Small update :
- improved README instructions
- improved styling, graphics
- removed cruft from /images directory
3.1.0.1 - published Oct 31, 2007
Uses web4j.jar version 3.1.0
Small update :
- amend the README file to clarify what's needed to get started
- add an example log file, to illustrate what a successful start looks like. The name of the
file is EXAMPLE_LOG_FILE.txt
- update the javadoc's overview.html
3.1.0.0 - published Oct 27, 2007
Uses web4j.jar version 3.1.0
Improvements :
- free-form user input - change to use SafeText instead of String.
- delete and log-off operations - change from a link (GET) to a form (POST).
- content-type - now specified explicitly at the start of each Template.jsp.
- CSRF defenses - added csrf.sql file, two SqlId fields in UserDAO,
filter in web.xml, and FormSourceId column to Users table in database.
- add .tag file for common menu items - Preferences, Help, Log Out.
- add .tag file for most of the HEAD tag content.
- focus - add javascript snippet to set focus to either first link on page, or first non-hidden control in form.
The focus is now more obvious, and allows easier mouse-free navigation.
Warning (seen in Firefox): some forms have a yellow background for first input element (Resto), some don't (Search).
May be related to browser prepopulating some form controls.
- Visit page - sorting of dates needs certain kind of formatting. Same with Report 3.
- images for checkboxes - when listing boolean items, using checkbox form controls has some problems :
the appearance of readonly items is not great, but using non-readonly items means the user can
alter the checkbox appearance simply by clicking (which is not appropriate for a listing). To avoid
these problems, a simple image can be used instead to indicate the boolean state.
This technique is now demonstrated with with the Members page.
- web4j.tld - add w:safe() function for escaping special HTML chars.
Fixes :
- Ratings page - form was not showing restaurant name (wrong reference).
- Diagnostics page - properly escape the output.
- Package-level description for hirondelle.fish.main.search referred to 'Fake Search', which does not exist (cruft).
- BaseText.jsp - TextFlow tag should have been inside the Populate tag, as per TextFlow javadoc.
- Visit_en.jsp, Visit_fr.jsp - broken with respect Add/Edit Operation param (was always adding, never editing)
- character encoding - was referenced in HEAD tag using a wrong name.
- TESTDateConverterImpl - should have passed TimeZone.getDefault() instead of 'null' in several places.
3.0.0.1 - published Sep 15, 2007
Uses web4j.jar version 3.0.0
- FIX: CodeTableUtil.populate() now returns null if Id is null. Was causing
NullPointerException in some Model Object constructors that took an Id.
- IMPROVE: edit of Ratings. Fail-of-edit now retains display of items being edited.
- IMPROVE: use 'FAILS == ...'for Checks, instead of ! operator, to increase legibility
3.0.0.0 - published Sep 8, 2007
Uses web4j.jar version 3.0.0
First published version.