You need the following software packages to get started. The Java SDK 1.4.1 or higher (http://java.sun.com/j2se) The Tomcat servlet container (http://jakarta.apache.org/tomcat/). The JavaServer Faces reference implementation (http://java.sun.com/j2ee/javaserverfaces) The sample code for this book, available at http://corejsf.com We assume that you already installed the Java SDK and that you are familiar with the SDK tools. For more information on the Java SDK, see Horstmann & Cornell, Core Java, Sun Microsystems Press, 2003. In this chapter, we describe how to use JSF with Tomcat 5. Tomcat is a servlet container: a program that serves web pages and executes servlets Java programs that process web requests. JavaServer Faces is built on top of the servlet technology, but you need not know anything about servlets to build JSF applications. Download and unzip Tomcat, the JSF reference implementation, and the sample code. Place them into directories of your choice. (As always, it is best to avoid path names with spaces, such as c:\Program Files.) In the rest of the book, we refer to these directories as tomcat, jsf and corejsf-examples. For example, if we refer to tomcat/conf/server.xml, you will need to look inside a directory such as /usr/local/jakarta-tomcat-5.0.19/conf or c:\jakarta-tomcat-5.0.19\conf. If you use Windows, you can choose a Windows installer for Tomcat instead of the platform-independent ZIP file. Download and execute the installer program. When you are prompted for the installation directory, we suggest that you use c:\tomcat instead of the default location inside the c:\Program Files directory. NOTE | You can run JSF applications with any servlet container that supports the Servlet 2.3 and JSP 1.2 specifications. To keep the instructions simple, we cover only Tomcat 5. If you prefer another servlet container, simply follow the standard procedure for deploying web applications on your server. |
NOTE | You can also obtain JSF from other sources, such as the J2EE SDK (http://java.sun.com/j2ee/download.html) or the Java Web Services Development Pack (http://java.sun.com/webservices/webservicespack.html). However, these bundles contain many other software components and have more complex configurations. We suggest that you move on to more sophisticated environments after becoming comfortable with Tomcat and the JSF reference implementation. |
Now you are ready to get started. Open a command shell and start Tomcat. On Unix/Linux, you use the command tomcat/bin/startup.sh (See Figure 1-1.) On Windows, launch tomcat\bin\startup.bat Figure 1-1. Starting Tomcat
Alternatively, if you used the Windows installer to install Tomcat, you can use the "Start Tomcat" menu item in the start menu. To test that Tomcat runs properly, point your browser to http://localhost:8080. You should see a welcome page (see Figure 1-2). Figure 1-2. Tomcat Welcome Page
You shut down Tomcat with the command tomcat/bin/shutdown.sh or, on Windows, tomcat\bin\shutdown.bat Alternatively, if you used the Windows installer to install Tomcat, you can shut down the running server by right-clicking the Tomcat icon in the system tray. |