ASP technology in WAP (3)
Author:Eve Cole
Update Time:2009-05-30 19:54:45
In the previous section, I explained the most basic concepts of WAP and WML. In this section we will take a look at how ASP and WAP are combined.
Section 4: Another way to book your movie tickets
Now in Oslo, cinemas provide a phone-based system to sell tickets. This system is very complicated, and some instructions must be given to users to guide them to buy tickets.
And the user must also find the code of a certain movie in the newspaper. This is very annoying. Let's introduce another method.
Here I will show you a simple WAP application that allows mobile phone users to book tickets: a service that is sure to impress. Users don't have to remember those annoying codes, they can choose movies and theaters directly from menus, and users don't need to authenticate. In this example the user is asked to pay 40 minutes before the movie starts, but in real life,
Users can also check out via mobile phone.
This application imagines that a movie can be shown in multiple cinemas at the same time, and that a cinema can show different movies at different times.
I don't think too much about error handling here, because it is not the focus of this chapter, you can add it yourself if you like.
For the sake of simplicity, I used Access 97 as the database. Of course, the real system will not use it. Other databases such as SQL Server do not need to change much code.
Database diagram
Database diagram
The .Movie and Theater tables are obviously required. The Show table is used to track how many vacant seats are currently available for sale.
How to debug this program
In order to access this WAP service, you need a WAP emulator. This program is mainly debugged on Nokia Toolkit 1.2. Please see the previous chapter for details.
Select movie
Select a movie in the list:
Here is the code:
<!--#include file="conn.asp" --><%
'send the right MIME type
Response.ContentType = "text/vnd.wap.wml"
The first thing is to declare wml. If the emulator does not declare XML in the right place, it will not accept WML. Although Nokia 7110 can ignore this, there is no guarantee that other phones will also work, so you have to do this. You also need to set the MIME type.
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
Before proceeding to the next card there will be a flashing screen showing an image in WBMP, a new format. This event is determined by the timer attribute. Here we set the time to 5 seconds. After the ontimer event is triggered, it will take you to another card. (wmbp’s photoshop plug-in can be downloaded for free from the Internet).
<card id="splash" ontimer="#card1" title="Welcome to">
<timer value="50"/>
<p align="center">
<br />
<img src="pix/logo.wbmp" alt="WAP movies"/>
</p>
</card>
<card id="card1" title="choose a film">
<%
sqlQuery = "SELECT [Movie_ID], [title] FROM Movie"
set rsMovies = conn.Execute(SQLquery)
:
%>
<p>
<select name='movie'>
<%
Do while not rsMovies.eof
response.write("<option value='" & rsMovies("Movie_ID") & "'>" & rsMovies("title") & "</option>" & vbcrlf)
rsMovies.MoveNext
loop %>
</select>
This part is the focus of this article. Read the required data from the database and display it. As an ASP programmer, there is nothing special about this, but it is different now that this simple program is used on a brand new server. This also makes me think that ASP is better than Java servlet in network programming of WML-based commercial websites.
<small>
<anchor title="next!">Next
<go href="step2.asp" method="get">
<postfield name="movie" value="$(movie)" />
</go>
</anchor>
</small>
</p>
Submission of forms can also be accomplished through soft switch functions (do and anchor). Here, I've done it with simple inline links because I feel it makes it feel intuitive and user-friendly. Postfields are about the same size as hidden in HTML, but wml variables do not need to be transferred in javascript like those in html. They can be written directly in wml, which has been explained in the previous section. The method of transfer here is The get and post methods are also supported in the WAP specification, and the emulator can also recognize it, but unfortunately, in Nokia 7110, this post is not supported, so you have no choice.