Java Reference
In-Depth Information
2. Enter lines 326 through 438 as shown in Figure 12-34 on the previous
page.
TextPad displays the code that outputs simple HTML Web pages when
an invalid user password or other log on error occurs (Figure 12-36). The
method returns a boolean value, indicating a successful or an unsuccessful
log on attempt.
HTML code
for WebStocks
Logon Error
Web page
HTML code
for WebStocks
Logon Error
Web page
HTML code
for WebStocks
Logon Error
Web page
FIGURE 12-36
Acquiring Data from a Web Service
As described in the requirements document, this application is to use a service
to obtain online quotes for one or more stocks. A Web service is an application
component service made available on a Web server for use by other Web-connected
programs. Web services are not designed for human interaction. They exchange
data over the Web from program to program and, thus, have no user interface.
Many Web services are standardizing on Extensible Markup Language
(XML) as a means of formatting and exchanging data. Extensible Markup
Language ( XML ) is a document markup language, similar to HTML in style,
but extensible, in that you can define your own custom tags. XML increasingly is
used to encode data transported over the Web. XML also is used to store server
configuration data for Tomcat, as discussed later in this chapter.
The Yahoo! stock quote Web service used in this application is a CGI program
that returns a list of data requested for one or more stock symbols, in a comma-
delimited format rather than in XML. A format that is comma-delimited is
textual data with the data fields delimited, or separated, by commas. Each record,
or group of related fields, typically ends with a new line (\n) or return (\r) char-
acter. Using the Yahoo! stock quote Web service involves connecting to the
proper URL, along with a series of URL encoded parameters, and receiving the
one or more lines of data returned, one stock per line. Connecting to a URL and
receiving a returned stream of data is an easy task in Java.
 
Search WWH ::




Custom Search