Table of Contents

preface xxv
acknowledgments xxvii
about this book xxix
about the cover illustration xxxiii

Introducing wireless development 1

Understanding WAP 3
The next big thing 3
The phone is different than a PC 5 ? The phone is better than a PC 7
How the wireless Web works 7
The Wireless Application Protocol 10
Why wireless requires new technology 12 ? Common WAP terms 14
Understanding wireless applications 14
The card and deck paradigm 15 ? Mobile markup languages 16
Your development target: the mobile phone 17
WAP development challenges 18 ? The phone user interface 19
Getting started 20
Summary 21
WAP application development platforms 22
Introduction 22
Working with emulators 23
UP.SDK 24
About UP.Simulator 25 ? Obtaining and installing UP.SDK 25 ? Creating and viewing a wireless application 27 ? Debugging your application 30 ? Reloading a document in the UP.Simulator 30 ? Configuring the UP.Simulator 30
Nokia WAP Toolkit 32
Obtaining and installing the Nokia WAP Toolkit 32 ? Using the Nokia WAP Toolkit 33 ? Creating and viewing an application 35 ? Debugging your application 35 ? Reloading a document to the phone simulator 36 ? Configuring the Nokia WAP Toolkit 36 ? Blueprint phone emulator 37 ? Nokia 7110 emulator 38
Summary 39

Introduction to WML 41

Getting started with WML 43
Introduction 43
What is WML? 44
Opening and closing tags 44
Learning by example: Hello World! 48
Understanding the code 49
Formatting text 50
Specifying font styles 51 ? Inserting a carriage return 51 ? Specifying reserved characters 53
Positioning text on the display 54
Wrapping text 54
Default line wrap mode 55 ? The Times Square wrap mode 55
Tables 55
Using table elements 55
Defining metainformation 57
Using the <head> element 57 ? Using the <access> element 57 ? Controlling deck caching using the <meta> element 59 ? Controlling bookmarking using the <meta> element 61
Summary 62
Navigating in WML 63
Introduction 63
Navigation basics 63 ? Planning your WML application 64
Using the task elements 65
Using the <go/> task element 65 ? Using the <prev/> task element 67 ? Using the <refresh/> task element 68 ? Using the <noop> task element 69
Defining tasks within WML 69
Using the <do> element 69 ? Using the <anchor> element 70 ? Placing a phone call with WML 72
Using menus for navigation 73
About backward navigation 75
About the history stack 75
Implementing card-level events 76
Using the attributes in the <card> element 77 ? Using the <onevent> element 77 ? Using the <timer> element 77
Implementing deck-level events 78
Using the <template> element 79
Summary 79
Getting information 81
Introduction 81
About menus 82
Overview of the WML menu elements 82 ? Using the < select> element 82 ? Using the <option> element 83 ? Using the < optgroup> element 86
Using input fields 87
Using the <input> element 88
Restricting data entry 89
Formatting input fields 89 ? Preformatting entry data 90 ? Ordering input fields 91
Images 91
Using the <img/> element 92 ? The WBMP image format 92 ? Using the ALT attribute 93 ? Icons 93
Summary 94
Using variables in WML 95
Introduction 95
Definition of a variable 96
About variables 96
Naming variables 97 ? Referencing variables 97
Setting variables 99
Setting variables implicitly 99 ? Setting variables using input fields 100 ? Setting variables using selection menus 101
Sending variables to server-side programs 103
Using the post method 104 ? Using the get method 105 ? Specifying the URL 107
Summary 108
Extending WML 109
Introduction 109
About extended WML elements 110
About context 111 ? Managing state in nested contexts 111
Implementing context 112
An example: variable state in a context 112
Navigating between contexts 114
Returning from a child context to the parent 115 ? Returning to the calling card 115 ? Returning to a specific card 115 Using the <throw> and <catch> elements 116
Passing variables between contexts 118
Sending variables to a child context 118 ? Receiving values from a child context 119
Summary 120

Introduction to WMLScript 121

Getting started with WMLScript 123
Introduction 123
Overview of WMLScript 124 ? Using WMLScript files 124
Structure and syntax 125
About variables 127
Declaring variables 128 ? Data type assumptions 129
First look: adding two numbers 130
The WML code: add.wml 130 ? The WMLScript code: add.wmls 131 ? The result 131
Summary 131
Using WMLScript statements and operators 132
Introduction 132
What a statement does 133 ? What an operator does 134
Statement types 135
Operators 140
Operator quick reference 143
Summary 144
WMLScript functions and pragmas 146
Introduction 146
Functions 147
Function declarations 147 ? Local functions 148 ? External functions 149
Library functions 149
Pragmas 152
URL pragma 152 ? Access pragma 153 ? Meta pragma 153
An example application?guessing a number 154
About the example application 154 ? The WML code 155 ? The WMLScript code 156 ? The result 157
Summary 158

Introducing HDML 159

Getting started with HDML 161
Introduction 161
Why learn HDML? 162
HDML syntax and structure 162
Commenting HDML code 164 ? The card/deck paradigm in HDML 165
An example: Hello World! 165
Formatting text 166
Specifying reserved characters 167 ? Positioning text on the display 168
Wrapping text 168
When to wrap versus Times Square 169
Summary 170
Building interactivity with HDML 171
Introduction 171
HDML interaction basics 172
Assigning actions to the Accept button 172
Using the <ACTION> element 173
Using the <A> element 176
Using the DEST attribute 177
User input cards 177
CHOICE cards 178 ? ENTRY cards 179
Controlling text entry 180
Entering different types of data 182
Using images 183
About images 183 ? Placing images within HDML 183 ? Using icons 185
Summary 185
Using variables in HDML 186
Introduction 186
About variables in HDML 187
Naming variables 188 ? Referencing variables 188
Setting variables explicitly 189
Using the <NODISPLAY> card 190
Setting variables implicitly 191
Using the CHOICE card 191 ? Using the ENTRY card 192
Putting it all together 193
The code 193 ? The result 194
Sending variables to server-side programs 194
Using the POST method 195 ? Using the GET method 195
Summary 196
Activities, bookmarks, cache, and access control 197
Introduction 197
How activities work 198
Navigating between activities 199
Using GOSUB 200 ? Using RETURN and CANCEL 200 ? Example: calling external applications 202 ? Example: providing help with activities 202
Using variables in activities 203
Using VARS 204 ? Using RETVALS 204 ? Using RECEIVE 205 ? Using CLEAR 205
Bookmarks 205
Disabling bookmarks 207
Using the phone?s cache 207
Using a cache to improve performance 208
About access control 208
How deck access works 209 ? Controlling deck access 209
Summary 210

Wireless application design issues 211

WAP design principles 213
Design considerations 214
The user 214 ? The device 215 ? The default phone 216
Design goals and guidelines 217
General design guidelines 218 ? Navigation guidelines 218 ? Text guidelines 219 ? Bookmark guidelines (Phone.com gateway only) 219 ? Image rules 220
Softkey label guidelines 221
Hyperlink guidelines 222
Other rules 222
Nokia browser considerations 224
Summary 225
Converting HDML to WML 227
Introduction 227
Things to keep in mind 228
Syntax conventions 228
Bookmarks 229
Emulating HDML card types in WML 230
Emulating actions 235
Emulating HDML activities in standard WML 236
Suggested strategy 236
WML versus HDML quick reference 237
Summary 242

Dynamic WAP applications with ASP 243

Introduction to Microsoft Active Server Pages 245
Overview of Microsoft Active Server Pages 245
Browser independence 247 ? ASP support for non-Microsoft web servers 247
Processing ASP documents 248
Writing ASP scripts 248
The ASP 3.0 object model 249
Working with built-in ASP objects 250
Retrieving values using the Request object 251 ? Displaying a message to the browser 252 ? Redirecting pages using Response 252 ? Buffering data using the Response object 253 ? Setting cookies using the Response object 254 ? Managing data caching using the Response object 255
Enabling information-sharing using the Application object 257
Setting application variables 257 ? Application.Lock and Application.Unlock methods 258 ? Scope of the application 259
Maintaining state 260
Setting session variables 260 ? Implementing sessions 261
Using the Server object 262
Server.Execute method 263 ? Server.Transfer method 263 ? Server.Transfer versus Response.Redirect 264
Handling application and session events using the global.asa file 265
Identifying a client type 266
Request.ServerVariables collection 267
Error handling in ASP 267
ASPError object 269 ? ASPError.ASPDescription property 269
Summary 270
Database connectivity with ADO 271
Database terminology 272
Relationships 273
Structured Query Language 274
The Open Database Connectivity technology 275
Components of ODBC 276 ? Setting up a data source name 277
Object linking and embedding databases 280
ActiveX Data Objects 282
Database connection types 282 ? Cursors 283
Database access using ASP 284
Retrieving records from a database 284 ? Adding a record to a table 286 ? Updating a record 290 ? Deleting a record 291 ? Navigating records 292 ? Searching for a record 294 ? Displaying records across multiple pages 295
Connection strings 299
Migrating to a database server 299
Changing the connection string 300
Summary 302
Using ASP to generate dynamic WAP content 303
Introduction 303
Creating a dynamic WAP application 304
Testing using WAP emulators 305
Step 1: editing an ASP document 305 ? Step 2: saving to the web-publishing directory 305 ? Step 3: using the emulators 307 ? Step 4: testing the look and feel 307
Sending and retrieving data 309
Passing values from client to server 309 ? Using the POST method 310 ? Using the GET method 310 ? A common pitfall using the GET method 311
Retrieving values sent to the server 311
Using the Request.Form collection 312
Session support in WAP devices 312
Using environment variables 313
Detecting web and WAP browsers 314
Detecting WAP devices 317
Testing using a real handset 319
Size constraints of WAP devices 320
Controlling page caching 320
Disabling caching 322 ? Caching on WAP gateways, proxy servers 323
Summary 324
Using ASP to implement data-based WAP applications 325
Introduction 325
Authentication by example 325
Logging on 326 ? Authenticating the logon 327 ? Handling an invalid logon 328 ? Entering new account information 329 ? Creating an account 330
Understanding mobile data entry 331
Packaging records with the <select> element 331
Record display by example 333
Displaying records across multiple pages 334 ? Understanding the code 334
Summary 337
Troubleshooting your ASP/WAP application 338
Errors and problems 338
ASP script errors 339 ? MIME type errors 341 ? Emulator problems 343 ? Web server and gateway configuration problems 343 ? Logical errors 343 ? User interface issues 344 ? Detecting the user device 344 ? Memory problems 345 ? Redirection problems 346 ? Performance problems 346 ? WMLScript support 347 ? Cookies problem 348
Summary 348

Dynamic WAP applications with Java technologies 349

Introduction to Java servlets 351
Overview of servlets 351
What are servlets 352 ? Why servlets 352
Software used for development 353
Servlet framework 354
Life cycle of a servlet 356
Initializing a servlet 356 ? Servicing client requests 357 ? Termination 358
Invocation of a servlet 358
Handling requests with service methods 359
Retrieving parameters from the client 360 ? Responding to the client 361 ? Generating dynamic HTML content 362
Summary 365
Database connectivity using JDBC 366
Introduction 366
Database connectivity APIs 367
Types of JDBC drivers 367
Basic tasks in database access 368
Loading the JDBC driver 368 ? Establishing a connection to the database 368 ? Formulating and executing SQL statements 369
Database-independent code 370
Accessing properties using InputStream 371 ? Accessing properties using ResourceBundle 371
Servlet example: library book search 372
Creating the front end 372 ? Creating a data store for book information 373 ? Servlet for retrieving book information 374
JDBC 2.0 features 378
Summary 379
Using Java servlets to generate dynamic WAP content 380
Generating dynamic WAP content 380
The role of the servlet 381
Generating output to WAP clients 382
Writing the response header information 382 ? Writing the response body 382 ? Creating a WAP application using a servlet 383 ? Viewing the result 384
Invoking a Java servlet 385
Calling a servlet from a card 385 ? Passing parameter values 387
Processing client requests 388
Retrieving header information 388 ? Retrieving parameter values 390 ? Understanding the code 391
Summary 393
Information tracking 395
Introduction 395
Cookie support in servlets 396
Adding and retrieving cookies 396 ? The Cookie class 396
Understanding cookies by example 397
Creating a cookie 397 ? Retrieving a cookie 399
Testing the example 401
Invoking PutCookieServlet 401 ? Invoking GetCookieServlet 403
Session support in servlets 404
Understanding session management 405
Overview of the shopping cart 405 ? Creating WML deck for selecting items 407 ? Displaying an empty-cart message 407 ? Creating the servlet 408
A shopping cart example 412
Selecting items 412 ? Viewing servlet results 412 ? Navigating from the acknowledgement screen 413 ? Navigating from the confirmation screen 414
Summary 414
Using Java servlets to implement database access 415
Introduction 415
Overview of the book inquiry system 416
System requirements 416 ? Program components 417 ? LIBRARY database 417
Creating the static WML decks 418
Creating the servlet 421
The doPost() method 422 ? Database programming issues 425 ? The bookDetails() method 426 ? The displayTitles() method 429 ? Good practices and common pitfalls 431
A book inquiry example 432
Summary 435
Introduction to JavaServer Pages 436
Introduction 436
How JSP works 437
A JSP example 437
Resources for running JSP 437 ? Example code 437 ? Running the example 438 ? Understanding the example 439
JSP container tags 440
JSP implicit objects 441
JSP standard actions 442
Server-side error troubleshooting 443
Compilation error 443 ? Run-time error 444
Summary 446
Developing email applications using Java 447
Introduction 447
What is an email message? 448
Overview of email protocols 449
Introduction to JavaMail 450
JavaMail architecture 450 ? JavaBeans activation framework 451 ? JavaMail classes and interfaces 452 ? JavaMail exceptions 453
Using JavaMail 454
Establishing a session with an email server 454 ? Composing and sending email messages 455 ? Retrieving email messages 456 ? Deleting email messages 459
JavaServer Pages 459
Sample WAP email application 461
Architecture of WAP email system 461 ? Sample application design 462 ? JSP component 464 ? Servlet component 468 ? Email Facade 471 ? Enhancements to sample application 474
Advanced WAP messaging technologies 474
Naming and directory services 475 ? Asynchronous notification of new messages 476 ? Email configuration 478 ? Unified communications 478 ? Security 479 ? Future direction 480
Summary 482

Transforming XML into wireless formats 483

Introduction to XML, XPath, and XSLT 485
Introduction 485
Transformations 486
What is XML? 488
Understanding XML markup 488 ? XML elements 492 ? Document type definition 495
What is XPath? 502
XPath data model 503 ? XPath expressions 504 ? XPath functions 508
What is XSLT? 511
XSLT template rules 513 ? Generating text: the xsl:value-of element 516 ? Repetition: the xsl:for-each element 516 ? Conditional processing: the xsl:if and xsl:choose elements 516
Simple XSLT style sheet example 517
The input document 518 ? The style sheet 519 ? How XML documents and XSL style sheets work together 521
Summary 522
XML parsers and XSLT processors 524
Introduction 524
XML parsers 525
About DOM and SAX 526 ? Microsoft XML parser 533 ? Xerces XML parser 533
XSLT processors 535
Microsoft XSLT processor 536 ? Xalan XSLT processor 537
How XML parsers and XSLT processors work together 539
A sample transformation: XML to HTML 541
MSXML and ASP 541 ? Xalan and Java 544
Tracing the transformation process 546
Tracing with Xalan 546 ? Tracing style sheet execution 547
Static versus dynamic transformations 550
Compiled style sheets 551
Summary 553
Implementing transformations 554
Introduction 554
Transformation to HDML using MSXML/ASP 555
Setting up a development environment 555 ? Understanding the product catalog 555 ? Designing the presentation 557 ? HDML elements 559 ? Defining the XSLT style sheet 560 ? Running the transform 565
Transformation to WML using Java 568
Setting up a development environment 569 ? Understanding the movie list 569 ? Designing the presentation 571 ? WML elements 573 ? Defining the XSLT style sheet 573 ? Running the transform 580
Transformation to VoiceXML using Java 585
An introduction to VoiceXML 586 ? A sample VoiceXML document 588 ? Setting up a development environment 589 ? Understanding the movie list 589 ? Designing the presentation 591 ? VoiceXML elements 593 ? Defining the XSLT style sheet 593 ? Introduction to TellMe Studio 600 ? Running the transform 602 ? Testing the application 604
Summary 608

Setting up a testing environment 609

Using WAP gateways 611
Introduction 611
WAP architecture revisited 612
Emulator versus gateway 613
Running your own gateway 614
Preparing to run a WAP gateway 614
WAPlite 616
Installing WAPlite 617 ? Starting WAPlite 617 ? Connecting to WAPlite using an emulator 619 ? Enabling cookie support in WAPlite 622
Nokia WAP Server 624
Downloading and installing the Nokia WAP Server 624 ? Starting Nokia WAP Server 625 ? Connecting using an emulator 626 ? Monitoring traffic 626 ? Converting HTML and text to WML 628
Hosting versus subscribing to WAP gateway 632
Deploying WAP gateway 633
Security of WAP-based systems 634
Cryptography 636 ? Digital certificates 637 ? Security in traditional communications 641 ? Security in WAP client-server communications 643
Summary 645
Configuring WAP devices 646
Introduction 646
Ericsson R320 647
Configuring Ericsson R320 for WAP services 647 ? Loading a WML deck 648 ? Options available during browsing 649
Ericsson R380 649
Configuring Ericsson R380 for WAP services 650 ? Loading a WML deck 652
Siemens S35 654
Configuring for WAP services 654 ? Loading a WML deck 655 ? Setting a home page 655
General tips on testing 655
Handling entry of long URLs 655 ? Connecting WAP devices to gateways 656
Summary 657

Case studies 659

Mobile inventory and ordering system 661
Introduction 661
Setup 662
Why use Microsoft Access? 662
Database structure 663
Table structure 663
System flow diagram 664
Welcome deck 666 ? The login deck 667 ? Authenticating the staff login 668 ? Performing the search 671 ? Displaying the book cover 674 ? Displaying detailed information 675 ? Viewing reservation information 680 ? Viewing detailed reservation information 681
Converting image files using a WBMP converter 684
Image types supported by pic2wbmp converter 685 ? Converting an image 685 ? Adjusting the size of the image 687 ? Saving the WBMP file 687
Summary 688
Mobile library system 689
Introduction 689
System design 690
Searching for a book 691 ? Renewing a book 692 ? Contacting administrator for interlibrary loan 693
Setup 693
Library database 693
Database structure 694 ? Table structure and contents 694
Code of the example 696
Database properties file 696 ? The welcome deck 696 ? The login deck 697 ? Authenticating user login 698 ? The main menu deck 701 ? Searching by title 704 ? Display-not-found and too-many-matches messages 712 ? Reserving a book 713 ? invalidPW.wml and rsrvSuccess.wml 719 ? Renewing books based on ISBN 720 ? Interlibrary book loans 722
Summary 727

Appendices 729


 
appendix A WML elements 731
appendix B WMLScript function libraries 752
appendix C HDML reference 777
appendix D Setting up PWS and IIS 793
appendix E HTTP/1.1 request and response headers 811
appendix F Java servlet packages 823
references 835
index 837