Table of contents

  1. Installation
  2. Running
  3. Available examples
    1. Hello World
    2. Recursive templating
    3. Number guess game
    4. Number guess game with continuations
    5. Friends listing
    6. Frames through inheritance
    7. Selective authentication
    8. Advanced continuations
    9. Stateful counters
    10. Hangman

table of contents

A. Installation

Download the examples archive, unzip it and use its directory as the webapps directory of your servlet container.

The supported servlet engines are (these are minimal version numbers, later versions work too):

Each web-application in the webapps directory contains a WEB-INF/lib directory. RIFE's jar file has to be copied there for each and every web application. This hasn't been done for you since it would dramatically increase the size of the examples archive.

The RIFE jar that corresponds to this release of the examples can be found in the ROOT/WEB-INF/lib directory.

Under a unix-like system (GNU/Linux for instance) you can do this quickly by executing the following bash script inside the webapps directory:

for f in `find . -name WEB-INF | grep -v ROOT`; do
mkdir -p ${f}/lib/;
cp ROOT/WEB-INF/lib/rife-*.jar ${f}/lib/;

Don't put this jar file in your servlet engine's lib, ext, or other engine-wide library location. Each web application needs to have its own private copy of the RIFE jar.

table of contents

B. Running

To be able to try out the examples, you now only have to start your servlet engine.

table of contents

C. Available examples

1. Hello World (browse source)

A typical first example that outputs Hello World to a web page.

2. Recursive templating (browse source)

Demonstrates advanced usage of the template engine by recursively constructing and displaying a tree structure.

3. Number guess game (browse source)

A simple number guessing game that shows how elements are chained together in a site structure through flowlinks and datalinks. An example of how to retrieve information from the visitor through a submission is also included.

4. Number guess game with continuations (browse source)

The same number guess game as above, but it has been implemented with web continuations instead. This clearly demonstrates the conciseness and logical grouping that web continuations bring to web applications.

5. Friends listing (browse source)

Uses basic database access to display a list of friends with links to their websites.

The application includes an administration interface for installing, populating and removing the database structure. Addionally, it's also possible to add new friends.
RIFE makes it possible to use Java Beans to centralize the creation of database structures, the validation of form data and the storage and retrieval of data. This examples demonstrates the latter with the tutorial.friends.backend.Friend bean.


A database instance has to be running and have been setup with the correct user and password. This example supports either PostgreSQL or MySQL. The JDBC driver are already included.

The database connection settings are defined in this file :


To make the application use one of the datasources that are defined there, the DATASOURCE parameter has to be set to the correct datasource name in this file :


6. Frames through inheritance (browse source)

Inheritance is used to automatically decorate certain urls with frames without having to be troubled by the maintenance of framesets.

7. Selective authentication (browse source)

Public pages are freely accessible, while other pages are protected through authentication. According to the user's role, acess is granted to protected parts of the site.

The login/logout box is perfectly isolated and shows how code can be re-used and transparently integrated through embedded elements.

8. Advanced continuations (browse source)

Continuations are used to handle the intermediate steps during an order checkout process. By providing a custom clone() implementation, the individual steps are prefilled with earlier submitted data if the user has pressed the back button.

9. Stateful counters (browse source)

Embedded elements are used as individual counters that handle their own state and submission events. The whole application has been written solely in Java, without any XML. The declarations of the embedded Counter element are provided through JDK 1.5 annotations. (this example doesn't work on JDK 1.4 because of the use of annotations)

10. Hangman (browse source)

A hangman word guessing game that interfaces with a structured model that is stored in the session. The whole application has been written solely in Java, without any XML. The declarations of the elements are provided through JDK 1.5 annotations. (this example doesn't work on JDK 1.4 because of the use of annotations)

table of contents

rifers.org web