Chapter 23, “Wireless Application Development Using WAP,” introduced the brave new world
of wireless development using the Wireless Application Protocol (WAP) and its client-side
technologies WML and WMLScript. This chapter will take a detailed look at WML and
WMLScript and will conclude with a discussion of wireless application development using
servlets. Although the process might sound daunting, you will find that it is very straightfor-
ward and not much different from developing traditional Web applications using Java servlets.
Both Web and wireless servlets applications output markup in text format in response to an
HTTP request. What differs is the form of the markup and the display and processing capabili-
ties of the client devices.
The Wireless Markup Language (WML)
WML is the markup language used by WAP for information display and form input. WML is
an XML-based (eXtensible Markup Language) language with a schema that is defined in the
Document Type Definition (DTD) located at:
For those not familiar with XML, the language differs from a markup language such as HTML
in that anyone can create their own set of custom tags and attributes (known as a schema ) to, in
essence, define a brand new language! The structure of this new language (that is, the
order/taxonomy in which the language elements interact) is stored in a Document Type
Definition file, or DTD. The DTD previously mentioned defines version 1.1 of the Wireless
Markup Language. Because a valid XML document must comply exactly with the rules
defined in a DTD, XML documents (and technologies such as WML) are very rigid. Therefore,
you can be reasonably sure that if a WML file is verified and compliant, it will run the same
way everywhere (barring browser bugs). Chapter 10, “Servlets and XML,” briefly described
the structure and symmetry of a valid XML file.
WML Language Basics
A valid WML file begins with a header (which states the XML version being used and the
appropriate WML DTD) and contains one body beginning and ending with a <wml></wml> tag
pair. One body can contain multiple cards (known as a deck ). Although only one card can be
shown at a time on a single device, variables can be maintained across cards. For example, the
output of one card's text field could be used as the input to another card's text field. As you
might have guessed, a card is defined within the <card></card> tag pair.
The Inevitable “Hello World!”
It had to come sooner or later: the inevitable “Hello World!” application, or in this case, WML
Card (see Listing 24.1).