21.1. At the Server-side
At the server side, the parameter name will be used to retrieve the form data. You can use your favorite server-side technology to do the processing required by your mobile Internet application. Some examples of server-side technology are ASP, Java Servlet, JSP, Perl and PHP.
21.1.1. ASP Version
Below is the processing.asp file that contains the ASP code for processing the form data submitted from our earlier WML document. What the ASP code does is very simple. It just prints out the form data received. In real WAP applications, the server probably needs to do more complicated processing. For example, storing the form data to a database such as MySQL, PostgreSQL, Microsoft SQL Server, Oracle Database, etc.
Remember to set the MIME type of the document to "text/vnd.wap.wml".
<?xml
version="1.0"?>
<!DOCTYPE wml PUBLIC
"-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<%
Response.ContentType = "text/vnd.wap.wml" %>
<wml>
<card
id="card1" title="WML Form">
<p>
Data
received at the server:<br/>
Name: <%
=Request.QueryString("name") %><br/>
Gender:
<% =Request.QueryString("gender") %><br/>
Which
part of our WML tutorial do you like?
<%
=Request.QueryString("tutorial_part")
%><br/>
temp_id: <%
=Request.QueryString("temp_id")
%>
</p>
</card>
</wml>
Let's say you enter "Andrew" in the input field, select the "I am a boy" option in the first selection list, select the "Part 1" and "Part 2" options in the second selection list and click the "Submit Data" link. The screenshots below show what you should see in some mobile phone browsers:
|
|
|
21.1.2. JSP Version
Below is the JSP version that produces the same result as the above ASP code:
<?xml
version="1.0"?>
<!DOCTYPE wml PUBLIC
"-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<%
response.setContentType("text/vnd.wap.wml");
%>
<wml>
<card id="card1"
title="WML Form">
<p>
Data
received at the server:<br/>
Name: <%=
request.getParameter("name") %><br/>
Gender:
<%= request.getParameter("gender") %><br/>
Which
part of our WML tutorial do you like?
<%=
request.getParameter("tutorial_part")
%><br/>
temp_id: <%=
request.getParameter("temp_id")
%>
</p>
</card>
</wml>
21.1.3. PHP Version
And here is the PHP version:
<?php
header('Content-type: text/vnd.wap.wml'); ?>
<?php echo
'<?xml version="1.0"?'.'>'; ?>
<!DOCTYPE wml
PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card
id="card1" title="WML Form">
<p>
Data
received at the server:<br/>
Name: <?php echo
$_GET["name"]; ?><br/>
Gender: <?php
echo $_GET["gender"]; ?><br/>
Which part
of our WML tutorial do you like?
<?php echo
$_GET["tutorial_part"]; ?><br/>
temp_id:
<?php echo $_GET["temp_id"];
?>
</p>
</card>
</wml>
Previous Page | Page 47 of 50 | Next Page |
- 1. WML (Wireless Markup Language) Introduction
- 2. WML Deck and Card
- 3. WML Document Structure
- 4. WML Generic Metadata: <meta>
- 5. Comments in WML
- 6. Line Breaking in WML
- 7. Font Size and Style in WML
- 8. WML Preformatted Text: <pre>
- 9. WML Images
- 10. WML Tables
- 11. WML Anchor Links
- 12. Programming Softkeys of Mobile Phones and the <do> Element
- 13. WML Template and Menu
- 14. WML Events and the <onevent> Tag
- 15. Timer and the ontimer Event
- 16. WML Event: onenterbackward
- 17. WML Event: onenterforward
- 18. WML Selection Lists and the onpick Event
- 19. WML Input Fields
- 20. WML Variables
- 21. Submitting Form Data to the Server in WML
- 22. Clearing a Saved Form in WML