Developing Wireless Applications with WAP, WML, and JSP
June 26, 2000
Consultant and JSP author Chad Darby delivered a light overview of a hot topic to a packed room at XML DevCon in New York on Monday, "Developing Wireless Applications with WAP, WML, and JSP."
"How many of you have cellular phones with you?" he opened the session. More than half the people in the crowd of about 300 raised their hands. "All right, now take them out, and turn them off." Darby, apparently, is no stranger to giving presentations to a technical audience. Folks laughed and some reached into their pockets to turn their ringers down, but even so, a half dozen times during his talk you could hear the electronic chiming of Beethoven's "Ode to Joy" or other synthesized tune trying to wrest an attendee's attention from Darby's presentation.
Darby's talk brought the wireless hype home to the XML opportunity that lies at its heart: there's never been a better reason to start storing data in XML, given all the predictions that more and more users will be trying to access that data over wireless phones. You can't serve HTML pages to phones, and even if you could it doesn't make any sense. Wireless users will want only a subset of the amount of information that web users expect from a page. Data stored in XML format is well suited for that kind of extraction.
Wireless Developer Resources
Wireless Developer Network
The aim of the course was to show how to use Java server pages to grab XML content and serve it to wireless and web users. Throughout, he showed how to use Phone.com's emulator (part of its software development kit) to test the WML (wireless markup language) code as you write it. Phone.com's microbrowser (v. 3.0 and v. 3.1) are the most common web browsers in North American Internet-ready phones. Nokia's browser is more popular on Europe's GSM phones, but even Nokia relies on Phone.com's browser in its North American CDMA phones.
WML deals with the small screen real estate by presenting its content in a deck-of-cards metaphor. "A document is a deck, and each section of that document is considered a card," Darby said. Tiny phone screens display one card at a time, and you move through them by clicking href's to the next card.
Here's a quick rundown of the steps for serving XML content to WML and HTML:
- Store your data in an XML format, compliant with your own or another DTD
- Create two stylesheets, one for HTML, the other for WML
- Use JSP to provide server-side XSL transformation.
An XML processor sits between the WML gateway and the XML data server, applying the appropriate stylesheet to the data. How does it know which stylesheet to apply? Checking the user agent is a solution that sometimes works within the limited universe of Netscape, Microsoft IE, Opera and a handful of others. But the rising number of wireless clients makes this problematic. Instead, Darby checks the HTTP header to see what type of data the user agent accepts. If it accepts mime type text/vnd.wap.wml, then he delivers the data as a list in the WML format. Otherwise, a table better suited for display on an HTML page goes out.
There are still a lot of bugs to work out before the wireless clients are as easy to serve to as web clients are. One gets the impression that the wireless telephone companies are not as used to working in an open environment as XML people may be used to. For example, most phones have the browser burned into the ROM. Want to upgrade to the 4.0 browser when it comes out? That's easy: toss your phone in the trash and buy a new one. Darby said that one manufacturer, Neopoint of San Diego, California, makes phones that let you upgrade the browser. We might expect other companies to follow suit -- except, of course, that the planned obsolescence is part of their revenue model.