Appendix E. Writing WML in Popular Development Languages

IN THIS APPENDIX

As explained in Chapter 2, "Introducing WML," WML is a client-side markup language, and it is used by devices (known as "user agents," or "UAs") to render and display content. WML content is generally created in two forms:

  • Static files contain only client content and no server-side programmatic processing. These usually reside on the server in the same form as they are delivered to the client. Because static files only contain client code, they are used for simple pages that require no intelligent processing.

  • Dynamic files are created on-the-fly on the server, and usually contain programmatic server-side processing. These files generate WML, but may contain code written in other languages too. Dynamic pages are used for database interaction, email integration, and all sorts of conditional and programmatic processing.

Content received on a WAP UA must be identified as WAP content. This identification is specified by the content MIME type, a string used to identify data. The MIME type for WML files is text/vnd.wap.wml, WMLScript files (see Chapter 9, "Using WMLScript") must have a MIME type of text/vnd.wap.wmlscript.

Caution

Unlike Web browsers, WAP UA's will not process or display content of any MIME type other than the recognized WAP types.


If you are creating static files, you usually do not have to worry about specifying MIME types. The WAP or HTTP server usually does this for you when it sees the wml file extension (assuming the Web server is configured correctly as explained in Chapter 2). But if you are creating dynamic content, your files will not have a wml extension (for example, Microsoft ASP files will have an asp extension, and Allaire ColdFusion files will have a cfm extension), and so specifying the MIME type is your responsibility.

Specifying MIME types is not complicated at all, although the exact syntax varies from one development language to the next. To help you create dynamic WAP content, this appendix provides sample syntax for the following popular development languages:

  • Allaire ColdFusion

  • Microsoft ASP

  • Perl

  • PHP

  • Sun JSP (Java Server Pages)

All the code listings used in this appendix create a simple card, as seen in Figure E.1. The WML source for this card is shown in Listing E.1. You'll notice that no MIME type is specified in the code; because the file has a wml extension this is taken care of for you.

Figure E.1. WML cards may be created statically or dynamically.


Listing E.1 hello.wml—Static WML Welcome Card
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd">

<wml>

   <card title="Welcome">
      <p>
         WAP is cool!
      </p>
   </card>

</wml>

Note

For simplicity's sake, all the listings in this appendix generate the same simple card. No intelligent back-end processing is performed in these examples, although your own code will likely include this.


Note

The examples here demonstrate specifying the MIME type for WML content. For WMLScript content you'd use the same syntax, just replacing the MIME type appropriately.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.204.208