Java Reference
In-Depth Information
Chapter 11: Building a Membership Web Site
In This Chapter
An area in which Java and databases are used together very frequently is in creating dynamic Web
sites. Part III of this topic illustrates the use of the JDBC Extension API in the context of a membership
Web site. The Web site is built around a membership database that incorporates a number of different
tables. This chapter discusses the design of this database.
The application design uses a three-tier architecture built around an Apache/ Tomcat -based Web server.
Apache and Tomcat provide HTTP service and Servlet/Java Server Pages (JSP) support, respectively.
Several alternative products can handle these tasks very adequately, but Apache and Tomcat have
several advantages over most of the others, not the least of which is that they both run on all common
platforms. Appendix B is a guide to downloading and installing Apache and Tomcat. Both are easy to
install and run on Windows or Linux/Unix platforms.
Another important reason for selecting the Apache server to provide HTTP service and is that Apache is
the most widely used server on the Internet at the present time, having been selected for over 60
percent of all web sites. This means, of course, that Apache is the server you are most likely to be using.
Similarly, Tomcat was chosen as the Servlet and JSP engine since Sun selected Tomcat as the
reference implementation for servlets and JSP applications, thus there is a high probability that you will
use it at some time. A final advantage is that both are available for free download from jakarta.org .
Designing a Multi-Tier System
Partitioning a design into tiers allows you to apply various off-the-shelf technologies as appropriate for a
given situation. For example, a browser displaying Web pages generated from JSP pages and servlets
in the Web tier handles the client tier. This means that all you have to do is comply with the HTTP
specifications and avoid any technologies that all the browsers you expect to encounter do not support.
Since the browser and the RDBMS are, essentially, off-the-shelf products with clearly defined interfaces,
the following chapters concentrate on the business and presentation logic required to interface to them.
The interface to the browser is handled through the Web server, which serves static Web pages and
provides a front end for Tomcat. Tomcat is responsible for serving the dynamic Web content created in
Java using servlets and JSP pages.
The structure of the three-tier system is shown in Figure 11-1 . On the left is the client machine running a
standard Web browser; in the center is the Web server; and on the right is the database server.
Figure 11-1: Three-tier Internet application
The business and data-presentation logic is handled using Java and JSPs in the Web-server tier. The
database itself can use virtually any RDBMS. The examples in the following chapters are based on SQL
Server and the Opta2000 drivers from Inet Software. This choice was made largely because the
Opta2000 drivers are a good example of a family of pure Java drivers that support the JDBC Extension
API, the primary topic of Part III of this topic. Opta2000 drivers are available for most major databases.
Just as you will almost certainly have no trouble figuring out how to change parts of the sample code
that refer to my user name, password, and server name, I am sure you will have no trouble figuring out
how to switch to a different RDBMS using different drivers. The degree of difficulty involved in either
case is similar.
Search WWH ::




Custom Search