Installing the Book Examples

All JSP pages, HTML pages, Java source code, and class files for the examples can be downloaded from the O’Reilly site http://www.oreilly.com/catalog/jserverpages3/.

They can also be downloaded from the book web site that I maintain: http://www.TheJSPBook.com/.

On this site you find a Download page where you can download the file, called jspbook3.zip. Save the file on your hard drive, for instance in C:\JSPBook on a Windows platform, and unpack it:

C:\JSPBook> jar xvf jspbook3.zip

You can use the same command on a Unix platform.

Two new directories are created: ora and src. The first directory contains all examples described in this book, and the second contains the Java source files for the JavaBeans, custom actions, servlets, and utility classes used in the examples.

The examples directory structure complies with the standard Java web application format described in Chapter 2. You can therefore configure any JSP 2.0-compliant web container to run the examples.

If you like to use a container other than Tomcat, be sure to read the documentation for that container for instructions on how to install a web application.

To install the example application for Tomcat, simply copy the web application directory structure (the ora directory) to Tomcat’s default directory for applications, called webapps. On a Windows platform, you can copy/paste the directory structure with the Windows Explorer tool, or use this command in a Command Prompt window:

C:\JSPBook> xcopy /s /i ora %CATALINA_HOME%\webapps\ora

On a Unix platform it looks like this:

[hans@gefion jspbook] cp -R ora $CATALINA_HOME/webapps

Recall from Chapter 2 that each web application in a server is associated with a unique URI prefix (the context path). When you install an application in Tomcat’s webapps directory, the subdirectory name is assigned automatically as the URI prefix for the application (that is, /ora in this case).

At this point, you must shut down and restart the Tomcat server. After that, you can point your browser to the ora application with the following URL: http://localhost:8080/ora/.

You should see a start page, as in Figure 4-3, that contains links for all examples in this book.

JSP book examples start page
Figure 4-3. JSP book examples start page

Get JavaServer Pages, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.