HansBergsten.com
Server-side Java technology resources
   
 
About Hans
ICanHelpSM FAQs Resources News Archive
 
   
 
Home
JavaServer Faces
   Examples Download
   Buy It
JavaServer Pages
   Examples Download
   Buy It
Java Enterprise
Best Practices

   Buy It
Articles
 
JavaServer Faces Examples
Download the JavaServer Faces Examples
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:
  1. Download the examples ZIP file and save it on your hard disk.
  2. 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.
  3. 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.
  4. The main application uses container-based authentication, so you need to define users for the roles employee and manager manager. If you're using Tomcat, the easiest way to do so is in the Tomcat conf/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>
                
  5. Restart the container and access the main example page with a URL like: http://localhost:8080/jsfbook/

Copyright © 2008 Hans Bergsten. Web hosting by Java Web Hosting