Chapter 10: Using JDO in a Web Application


This chapter describes a rental Web application that satisfies the requirements of the fictitious Maine Lighthouse Rental Company. The rental Web application allows a user to identify himself, view available rentals, and make and cancel reservations. The rental Web application meets virtually the same set of requirements as was met by the rental Swing application presented in Chapter 9. This chapter presupposes that you have read Chapter 9, which explains the use cases for the rental applications, and that you have built the rental Swing application. Because the Swing version of the rental application is the only version that can initialize the datastore with the testing data, you must build and use that version before building the rental Web application.

The application data classes, data service, and data model are maintained in distinct source files for the Web application and the Swing application. Although the differences between the versions are small enough that they could be merged together, separate versions are maintained to avoid obscuring the differences between them.

Configuring the Build Environment for Tomcat

The rental Web application is part of the JDO Learning Tools. Chapter 8 describes how to configure the build environment and execute builds. If you have followed the instructions presented in Chapter 8 successfully, you are ready to perform the additional configuration steps presented here. If you did not perform the configuration described in Chapter 8, you must perform all seven configuration steps described in Chapter 8. Thereafter, continue with the following three configuration steps, which allow you to build the rental Web application.

Step Eight: Set Up Tomcat Servlet Container

In this step, you set up the Tomcat servlet container. The build in this chapter was developed using Tomcat 4.1.12. Any Tomcat 4.x build should work equally well. If you do not have a 4.x version of Tomcat installed, go to the following URL:

http://jakarta.apache.org

Follow the links to a download of Tomcat. Then follow the directions to install it and start it up. If Tomcat is properly installed and running, the URL http://localhost:8080 displays the default Tomcat home page.

The directory where you installed Tomcat is referred to as tomcat-home in this book.

Estimated time for this step, excluding download: 45 minutes

Step Nine: Set Up JSP Standard Tag Library

In this step, you set up the JSP Standard Tag Library (JSTL). The rental Web application's JavaServer Pages (JSPs) use the core tags of the JSTL. The reference implementation of the JSTL is a product of the Jakarta group at Apache. The build in this chapter was developed using JSTL 1.0.1. Any 1.x version should work, although you want to make sure that the distribution that you download has the standard-doc and standard-examples WAR files. If you do not have the JSTL, go to the following URL:

http://jakarta.apache.org/taglibs

Follow the links to the JSTL download. Then follow the directions to unzip it. Next, copy the contents of the JSTL lib directory to the shared/lib directory under your tomcat-home directory.

Copy the standard-doc and standard-examples WAR files from the JSTL distribution to the web-apps subdirectory under the tomcat-home directory. Restart Tomcat, and go to the following URL:

http://localhost:8080/standard-doc

You should see the welcome page for the JSTL.

Estimated time for this step, excluding download: 15 minutes

Step Ten: Configure Build Environment

In this step, you configure the build environment for building the rental Web application and deploying it to Tomcat. Edit the default.properties file in the bookants directory under your bookcode-home directory. Set the tomcat.home property to point to your tomcat-home directory.

If you are using a version of JSTL later than 1.0.1, copy the c.tld file found in the JSTL distribution to the com/ysoft/jdo/book/rental/servlet/misc directory under your bookcode-home directory.

Copy the jdo.dtd file found in the bookcode-home directory to the bin directory under the tomcat-home directory.

Estimated time for this step: 5 minutes

At this point, you are ready to build the rental Web application.




Using and Understanding Java Data Objects
Using and Understanding Java Data Objects
ISBN: 1590590430
EAN: 2147483647
Year: 2005
Pages: 156
Authors: David Ezzio

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net