WAP for Java developers - JavaWorld June
2000
Tutorial Details:
WAP for Java developers
WAP for Java developers
By: By Qusay H. Mahmoud
Develop WAP applications with Java servlets and JSP
ost Internet technologies have been designed for desktop and large computers running on reliable networks (with relatively high bandwidth). Handheld wireless devices, however, have a more constrained computing environment compared to desktop computers. Handheld devices tend to have less memory, less powerful CPUs, different input devices, and smaller displays. Further, wireless networks have less bandwidth and more latency compared to wired computer networks.
WAP, the Wireless Application Protocol, was designed to take advantage of the several data-handling approaches already in use. WAP integrates the Handheld Device Markup Language (HDML) and the Handheld Device Transport Protocol (HDTP) developed by Unwired Planet (now known as Phone.com), as well as Nokia's Smart Messaging Protocol (SMP), and Ericsson's Intelligent Terminal Transfer Protocol (ITTP). WAP services can be hosted on Web servers using technologies such as Java servlets and JavaServer Pages (JSP). In this article, I show you that WAP and Java are complementary, not competing, technologies. WAP is meant for cellular phones, and Java aims at more sophisticated network terminals.
The WAP platform is an open specification that addresses wireless network characteristics by adapting existing network technologies (and introducing new ones where appropriate) to the special requirements of handheld wireless devices. Therefore, WAP intends to standardize the way wireless devices (mobile phones, PDAs, and so forth) access Internet data and services. WAP's reuse of existing Internet protocols will ease the development of WAP services for Java and other Web developers.
To facilitate the delivery of Internet data to wireless devices will certainly lead to the introduction of new technology. For example, wireless devices have small screens compared to desktop computers, and therefore HTML (which is visually rich) is not appropriate for small screens. The small screen and the computing power, which is increasing, represent a limiting factor in running complicated Java applications with intensive graphics. However, efforts are being made for having a compact subset of the Java language suitable for mobile applications. In this article, you learn how to develop WAP applications using Java servlets and Java Server Pages.
But first, I describe the WAP platform and how it incorporates several technologies that are similar to existing ones but that have been designed specifically for wireless devices.
The WAP architecture
The WAP standard defines two essential elements: an end-to-end application protocol and an application environment based on a browser. The application protocol is a communication protocol stack that is embedded in each WAP-enabled wireless device (also known as the user agent). The server side implements the other end of the protocol, which is capable of communicating with any WAP client. The server side is known as a WAP gateway and routes requests from the client to an HTTP (or Web) server. The WAP gateway can be located either in a telecom network or in a computer network (an ISP). Figure 1 illustrates an example structure of a WAP network.
Figure 1. The WAP network structure
In Figure 1, the client communicates with the WAP gateway in the wireless network. The WAP gateway translates WAP requests to WWW requests, so the WAP client is able to submit requests to the Web server. Also, the WAP gateway translates Web responses into WAP responses or a format understood by the WAP client.
The WAP programming model
The WAP programming model is similar to the Web programming model with matching extensions, but it accommodates the characteristics of the wireless environment. Figure 2 illustrates this model.
Figure 2. The WAP programming model
As you can see, the WAP programming model is based heavily on the Web programming model. But how does the WAP gateway work with HTML? In some cases, the data services or content located on the Web server is HTML-based. Some WAP gateways could be made to convert HTML pages into a format that can be displayed on wireless devices. But because HTML wasn't really designed for small screens, the WAP protocol defines its own markup language, the Wireless Markup Language (WML), which adheres to the XML standard and is designed to enable powerful applications within the constraints of handheld devices. In most cases, the actual application or other content located on the Web server will be native WAP created with WML or generated dynamically using Java servlets or JSP.
In HTML, there are no functions to check the validity of user input or to generate messages and dialog boxes locally. To overcome this limitation, JavaScript was developed. Similarly, to overcome the same restrictions in WML, a new scripting language known as WMLScript has been developed. I'll cover more on WML and WMLScript in later sections.
The WAP protocol stack
To minimize bandwidth requirements, and guarantee that a variety of wireless networks can run WAP applications, a new lightweight protocol stack called the WAP protocol stack was developed. Figure 3 illustrates this stack protocol and also shows a comparison to a Web-based protocol stack. (The layer acronyms can be translated to Wireless Application Environment, Wireless Session Protocol, Wireless Transaction Protocol, Wireless Transport Layer Security, and Wireless Datagram Protocol, respectively).
Figure 3. The WAP protocol stack
The WAP protocol stack has four layers: session layer, transaction layer, security layer, and datagram layer. Note that the WAP protocol is designed to operate over a variety of bearer services, including Code Division Multiple Access (CDMA), Cellular Digital Packet Data (CDPD), and so forth.
WML
The Wireless Markup Language (WML) is an XML-based markup language that was designed to describe how WAP content is presented on a wireless terminal. WML differs from HTML in the following:
WML was specifically designed for wireless terminals with a target screen that is only a few lines long and about an inch wide.
WML is case sensitive, and all tags and attributes should be in lowercase.
Unlike HTML, WML is unforgiving of incorrectly nested tags.
WML doesn't assume that a "QWERTY" keyboard or a mouse is available for user input.
Based on these differences, WML provides a smaller, telephony-aware set of tags that make it more appropriate than HTML for handheld wireless terminals. Similar to HTML, though, with WML you can give the user input options and specify how the user agent should respond when, for example, the user presses a key.
The genesis of WML
The basic unit of WML is the card that specifies a single interaction between the user and the user agent. Multiple cards are grouped together in decks. A deck is the topmost element of a WML document. When the user agent receives a deck (by downloading the complete deck), it activates only the first card in the deck. Listing 1 shows a sample WML document with a single card:
Listing 1. Example1.wml
"http://www.wapforum.org/DTD/wml_1.1.xml">
My First WML Example
When viewed on a WAP-enabled phone, Listing 1 is rendered and displayed as shown in Figure 4.
Figure 4. The result of
Example1.wml
As I mentioned before, WML is based on XML. Therefore, a deck has to be a valid XML document, which implies that a WML document (as the one shown in Listing 1) should start with the standard XML header and the reference to the WML DTD. The tag delimits a paragraph and must be used to wrap any text you want to display.
Now, take a look at an example that has two cards and uses other WML features. Listing 2 shows the Ottawa City Guide example.
Listing 2. Example2.wml
"http://www.wapforum.org/DTD/wml_1.1.xml">
Business
Education
Entertainment
Restaurants
Shopping
Travel
Weather

Canadian
Chinese
Continental
French
German
Greek
Italian
This example was developed using the Ericsson WapIDE (WAP integrated development environment). WapIDE is shown in Figure 5 along with the output of Listing 2.
Figure 5. Ericsson's WapIDE.
Click on thumbnail to view
full image (53k)
The example in Listing 2 has two cards: city and food. When a device receives this deck, it loads the first card automatically as shown in Figure 6.
Figure 6. The first card
Once the city card is loaded, you can navigate through it using the soft key on your device. Figure 7 shows what happens when the Restaurants option is selected.
Figure 7. The Restaurants option
Navigation in this example is implemented using anchors ( ), which are the WML counterpart of tags in HTML. An anchor can be defined as:
Go to food
This is identical to:
Go to food
In the preceding examp
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: WAP for Java developers - JavaWorld June
2000
View Tutorial: WAP for Java developers - JavaWorld June
2000
Related
Tutorials:
Will Big Blue
eclipse the Java
tools market?
Will Big Blue
eclipse the Java
tools market? |
Master J2ME for live data
delivery
Master J2ME for live data
delivery |
Check out three
collections libraries
Check out three
collections libraries |
Sun boosts
Sun boosts enterprise Java |
High-availability mobile applications
High-availability mobile applications |
Using SSL with Non-Blocking IO
Using SSL with Non-Blocking IO
After the initial experiments with Java NIO, most developers start wondering about security; in particular, how to use SSL with Java NIO. With the traditional blocking sockets API, security is a simple issue: just set up an |
JTwain
JTwain will implement a Java interface to the the Win32 C DLL TWAIN acquire methods. |
JTimepiece
JTimepiece is the advanced library for working with dates and times in Java. Many easy-to-use methods in this API make it easy for any developer, from beginner to expert, to use JTimepiece. |
Object-Oriented Language: Java / APIs (Classes & Libraries)
The Java Platform APIs are a set of essential interfaces that developers need to build their Java applications and applets. All Java Platfrom APIs are open and extensible, and are created by JavaSoft and industry-wide specialists in each target technology |
Java Resources
There are all Java freebies. Some of these are old, and not under maintenance. Download and use them at your risk. In case of queries, mail subrahmanyam_avb@technologist.com or varalakshmi_a@techie.com. |
Develop WAP Applications with Java Servlets and JavaServer PagesTM
WAP, the Wireless Application Protocol, was designed to take advantage of the several data-handling approaches already in use. WAP integrates the Handheld Device Markup Language (HDML) and the Handheld Device Transport Protocol (HDTP) developed by Unwired |
JSP Escape taglib ver. 1.83
Also useful for WAP/WML developers - converts on the fly HTML to WML. Library has got two body tags Escape and WmlEscape. |
JSPTags.com offers JSP developers a directory of resources.
JSPTags.com offers JSP developers a directory of resources related to JavaServer Pages, Servlets and Java. As the name JSPTags.com implies, special interest is given to JSP Tag Libraries. Many developers are working with and designing new JSP Tag Librarie |
Tutorial for Developing your first JSPs tags
We have seen how servlets and JSPs can be used to build a web application. These technologies go some distance toward making web development easier, but do not yet facilitate the separation of Java from HTML in a reusable way. Custom tags make this possib |
Struts, JavaServer Faces, and Java Studio Creator:
The Evolution of Web Application Frameworks Sun Microsystems' Craig McClanahan, the creator of the Apache Struts Framework, co-specification lead for JavaServer Faces 1.0, and prime architect for Sun Java Studio Creator's new release, explains all three. |
Parisonz Solutions!
Parisonz Solutions!
W elcome to Parisonz Solutions . The purpose of this web is to Develop and Distribute Projects to Businesses and Individuals though Web. We have a wide range of projects completed online — including software development, web |
Writing more than one cards in a WML deck.
Writing more than one cards in a WML deck.
Tutorial
First Card
Writing more than one cards in a deck.
In this lesson we will write application that uses two cards in a deck. First card is displayed only for some time and after that it directly |
What is WAP? Detailed discussion of WAP API with examples.
What is WAP? Detailed discussion of WAP API with examples.
Learn WAP in 60 minutes
W ireless Application Protocol or WAP for short, allows the developers to develop next generation web application for cellular devices. Through WAP enabled mobile |
WAP Toolkits Motorola - Mobile ADK 1.1 Nokia - WAP Toolkit
WAP Toolkits Motorola - Mobile ADK 1.1 Nokia - WAP Toolkit
Tutorial
WAP Toolkits
T o develop any WAP application you have to download software essential for development. Although you can write and test your codes through our site for learning |
What is WAP? Wireless Application Protocol
What is WAP? Wireless Application Protocol
Tutorial
What is WAP?
W ireless Application Protocol or WAP for short is simply a protocol - a standerized way for delivering Internet data over wireless networks. Thus WAP links Wireless Network with |
|
|
|