Java Reference
In-Depth Information
Introduction
In earlier chapters, the programs were designed to be used by one person at one
time on one computer. Even when multiple classes were used for different pur-
poses, such as separating interaction with a database from the user interface, you
still were working with a single program running on the computer where the
program was stored. Today, with the Internet playing a key role in how people
use computers, applications that originally were designed for use on a single
local computer now are Web-enabled , meaning they utilize a connection to a
Web server and can be accessed from anywhere in the world.
As you learned in Chapter 1, many programmers use Java servlets to develop
database-driven applications for a variety of purposes and deploy them over
intranets, extranets, and the Web. For example, if a company's human resource
department needs to deploy an employee benefits application that is accessible
via the Web, a programmer can use Java servlets, JavaServer Pages, and JDBC™
to develop a program to meet those needs.
In this chapter, you will learn how to create a Web-enabled version of the
StockTracker application as a servlet, as well as how to add functionality not
available to a local, or nonnetworked, version. The Model-View-Controller
(MVC) pattern discussed in Chapter 11 — which involves the separation of the
user interface from the controlling logic of the program and from the interaction
with the database — will be discussed further in this chapter. You will learn how
to use servlets and JavaServer Pages (JSPs) to provide dynamic Web page con-
tent. The user interface takes the form of Web pages displayed in a Web browser
on a client machine, while the application logic moves to a Web server capable of
executing a Java servlet. The data access class, StockTrackerDB, from the previous
chapter is used once again to interact with the database. You will learn how to
implement session tracking with HTTP, limiting transactions to users who have
successfully logged on to the system. Finally, you will use the application to
access a Web service, thus providing a quote for a selected stock.
Chapter Twelve — The Webstocks Web Application
MoneyMark Trading liked the previous StockTracker application developed for
tracking stock holdings; however, as many applications now are being offered
over the Web, they want this application to be Web-enabled so they can make it
available to clients via their Web site. In addition to providing the functionality
of the previous application, the new Web-enabled version, called the WebStocks
Web application, should utilize Web connectivity to obtain online stock quotes
as requested by the user.
The user will interact with this application through Web pages displayed on
the client machine (Figure 12-1a). The browser, therefore, is the client software
responsible for displaying the user interface. Web pages, either static or dynamic,
are provided by a Web server (Figure 12-1b). A static Web page is a Web page
that exists in its entirety on the Web server before it is used. The content of a
static Web page does not change with each use. A dynamic Web page is a Web
page that is created as needed and usually is customized upon each use. A
dynamic Web page often contains data extracted from a database.
Search WWH ::




Custom Search