Home > Articles > Programming > Java

A Brief Introduction to WML

As you now know, WML is based on XML and is optimized for low-bandwidth transactions. One of the optimizations in WAP and WML is that a server can return multiple display pages in a single request. These display pages are referred to as cards. When you return a response to a WAP phone (or other device), the response can contain a series of <card> tags. The phone displays the first card in the response, and it is up to you to provide navigation to the other cards.

Navigating Between Cards

There are two main ways to navigate between cards. You can use the <a> tag, which creates a hyperlink just like in HTML, or you can use the <do> tag which lets you perform an action when the user presses a particular key or activates some other feature of the device.

The following listing shows an example page with four cards. The main card contains three hyperlinks to the other cards. In a WML hyperlink, the text after the # in a URL indicates the card name. For example, href=”#moe” refers to the card with an ID of moe.

<%@ page language="java" contentType="text/vnd.wap.wml" %>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<card id="main">
    <p>
        <a href="#moe" title="Moe">Moe Howard</a>
        <a href="#larry" title="Larry">Larry Fine</a>
        <a href="#curly" title="Curly">Curly Howard</a>
    </p>
</card>

<card id="moe">
    <p>
        Moe Howard<br/>
        Why I oughta...
    </p>
</card>

<card id="larry">
    <p>
        Larry Fine<br/>
        Ow! Ow! Ow!
    </p>
</card>

<card id="curly">
    <p>
        Curly Howard<br/>
        Woob woob woob woob<br/>
        Nyuk nyuk nyuk
    </p>
</card >
</wml>

In addition to hyperlinks, you can control navigation based on the keys the user presses. When you control navigation by key presses, you can look for the keys either within a particular card or within the entire deck.

TIP

A WML page is referred to as a deck because it usually consists of a number of cards.

The following listing shows a Web page similar to Hyperlinks.jsp, except that you use the Accept keys to navigate forwards through the list.

<%@ page language="java" contentType="text/vnd.wap.wml" %>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<card id="moe">
    <!-- If the user presses Accept, display the Larry card -->
    <do type="accept" label="Larry">
        <go href="#larry"/>
    </do>
    <p>
        Moe Howard<br/>
        Why I oughta...
    </p>
</card>

<card id="larry">
    <!-- If the user presses Accept, display the Curly card -->
    <do type="accept" label="Curly">
        <go href="#curly"/>
    </do>

    <p>
        Larry Fine<br/>
        Ow! Ow! Ow!
    </p>
</card>

<card id="curly">
    <!-- If the user presses Accept, display the Moe card -->
    <do type="accept" label="Moe">
        <go href="#moe"/>
    </do>
    <p>
        Curly Howard<br/>
        Woob woob woob woob<br/>
        Nyuk nyuk nyuk
    </p>
</card >
</wml>

NOTE

The Accept key is usually right below the display. On some phones, it's on the right; on others, it's on the left. The phone usually gives you a clue by placing the label string on the side where the Accept key is.

Remember, too, that not all phones have a Back key. You need to make sure that the user can navigate around from whatever card he is on. For example, in the Hyperlinks example, you can't get back from any of the specific cards unless you have a Back key.

Creating Input Forms

Although WML doesn't have a <form> tag like HTML, you can still create input forms and process them as if they were HTML forms. The <input> tag creates an input field much like its HTML equivalent. When you create an input field, you must give the field a name, but all other attributes of the tag are optional. You may specify size and maxlength, just like in HTML. The type attribute may be text or password, with text being the default. One of the interesting options is that you can specify a format.

The format is a list of characters indicating what kinds of values can be entered at each position in the field. The format characters are A, a, M, m, N, X, and x.

A format of A permits any uppercase character except a number. A format of a allows any lowercase character except a number. A format of M allows any character (including symbols and numbers) and defaults the first character to upper case. A format of m allows any character and defaults the first character to lower case. The N format allows only numbers. The X and x formats allow any uppercase or lowercase characters, respectively, plus any symbols or numbers.

Normally, a format character represents a single position in the field. For example, if you specify a format of NANA, you require the first and third characters to be numbers, and the second and fourth to be letters.

If you put an asterisk before a character, you allow any number of those characters. For example, if you want a format that allows a single letter followed by any number of digits, use A*N. If you want a format that allows any character but requires at least one, use M*M. Remember, the * can represent 0 characters.

TIP

When creating format strings for an input field, remember that the * is associated with the character to its right, not its left. In most other wildcard formats, the * is associated with the character to its left.

You can also use a specific count instead of the *. For example, if you want to require exactly four letters, you could use either AAAA as a format, or simply 4A.

NOTE

The * and the count format options can be applied only to the last format character. In other words, you can't do something like A*AN.

The following <input> tag allows only letters and requires at least two letters:

<input name=”atleasttwo” format=”AA*A”>

You can also insert fixed characters in the format text by preceding that character with a \. For example, a field that allows you to enter a Social Security number looks like this:

<input name=”ssn” format=”NNN\-NN\-NNNN”>

You can also create select lists using the <select> and <option> tags like you do in HTML. Here is a select list that allows you to pick a color:

<select name=”color”>
    <option value=”r”>Red</option>
    <option value=”g”>Green</option>
    <option value=”b”>Blue</option>
</select>

Processing Form Input

One of the unique things about WML is that it makes the values of input and select fields available within the deck. You can reference the value of a field by putting a $ in front of the field name. The following listing shows a single-card deck with a text input field and a select list. Between the input field and the select list, it prints out the value from the input field.

<%@ page language="java" contentType="text/vnd.wap.wml" %>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<card id="fieldfun">
<p>Type something:
    <input name="ssn" format="NNN\-NN\-NNNN"/>
    $ssn
    <select name="colors">
        <option value="r">Red</option>
        <option value="g">Green</option>
        <option value="b">Blue</option>
    </select>
</p>
</card>
</wml>

The $ssn symbol right before the <select> tag inserts the value from the text field into the output from the card.

NOTE

Notice that the phone image in the Phone.com simulator is different than the one you saw before. The Phone.com simulator comes with different configurations so that you can see what a page would look like in several different phones.

To post a form to a Web server, use the <do> tag to define an action for a keypress and a <go> tag to define the action to be taken. Within the <go> tag, you use <postfield> tags to specify the values you want to send. The following listing shows how you would post the values from Input.jsp back to a Web page called HandleInput.jsp.

<%@ page language="java" contentType="text/vnd.wap.wml" %>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<card id="fieldfun">
<do type="accept">
    <go href="HandleInput.jsp" method="post">
       <postfield name="ssn" value="$(ssn)"/>
       <postfield name="colors" value="$(colors)"/>
    </go>
</do>

<p>Type something:
    <input name="ssn" format="NNN\-NN\-NNNN"/>
    $ssn
    <select name="colors">
        <option value="r">Red</option>
        <option value="g">Green</option>
        <option value="b">Blue</option>
    </select>
</p>
</card>
</wml>

The form input is delivered to your servlet or JSP exactly the same way is it is when it comes from a browser.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020