You can download all the book examples, including the Java source code for the sample application and all custom JSF code, and install them locally as described in Chapter 3. All you need is included in this file: jsfexamples.zip. |
To run the examples on your own desktop or server, you need a Servlet 2.4/JSP 2.0 compliant container, such as Apache Tomcat 5.0.18 or later.
How to install the examples for Tomcat, or any other compliant web container, is described in detail in the book. Briefly, this is what you need to do to run the examples:
- Download the examples ZIP file and save it on your hard disk.
- Unpack the contents of the file with either a ZIP utility program (such as WinZip) or the jar command that’s included in the standard Java environment. The file contains two directories: jsfbook and src.
- The jsfbook directory contains the book examples arranged in the structure specified by the Servlet 2.2 specification for web applications archives (WAR files), which is supported by most containers also as an open file system structure. For Tomcat, just copy the jsfbook directory and all its subdirectories under Tomcat’s webapps directory. For other containers, see their documentation for how to install a web application.
- The main application uses container-based authentication, so you need to define users for the roles
employee
andmanager
manager. If you’re using Tomcat, the easiest way to do so is in the Tomcatconf/tomcat-users.xml file:<tomcat-users> <role rolename="employee"/> <role rolename="manager"/> <user username="mike" password="boss" roles="manager"/> <user username="hans" password="secret" roles="employee"/> </tomcat-users>
- Restart the container and access the main example page with a URL like:
http://localhost:8080/jsfbook/