|
Advanced WAP Programming
How to generate dynamic WAP pages using ASP, PHP, Perl, or JSP
Wednesday, January 03, 2001
To do some serious work in WAP (Wireless Application Protocol), you’ll need
dynamically generated pages that can pull data from within databases. WML
(Wireless Markup Language), which is used to create static WAP pages, can’t be
used for database connectivity because it’s a static markup language like
HTML. You need to write server-side scripts for database connectivity, for which
you can use PHP, Perl, JSP or ASP. Here, we’ll show you how to use these.
Before you start scripting, you have to configure your Web server for serving
WAP pages. You also need a good toolkit, which will emulate a WAP phone, so that
you can see what will be seen on the cellphone screen.
WAP toolkits
Various toolkits are available in the market, the most widely used ones being
the Nokia Toolkit 2 available at www.forum.nokia.com
and the UP Phone Toolkit at www.developer.phone.com.
Web server configuration
When a Web browser receives a page, it has to distinguish between HTML,
image, audio, and video. To enable this, with every response from the Web
server, a piece of header information is sent to the browser. This is known as
MIME (Multipurpose Internet Mail Extension). Some of the common MIME types
include text/html for HTML files and image/gif for GIF files. To enable the Web
server to serve WAP documents, it needs some new MIME types. These include:
Extension MIME type
WML text/vnd.wap.wml
WMLC application/vnd.wap.wmlc
WMLSC application/vnd.wap.wmlscriptc
WMLSCRIPT text/vnd.wap.wmlscript
WS text/vnd.wap.wmlscript
WSC application/vnd.wap.wmlscriptc
WMLS text/vnd.wap.wmlscript
WBMP image/vnd.wap.wbmp
The procedure for adding these MIME types varies from server to server. We’ll
do this for some common Web servers here. When you do this for your server, it
would be a good idea to check the documentation for the Web server you’re
running.
Apache
Locate the httpd.conf file (in /etc/httpd/conf), file and add the following
lines:
# WAP MIME Types
AddType text/vnd.wap.wml .wml
AddType image/vnd.wap.wbmp .wbmp
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlc .wmlc
AddType application/vnd.wap.wmlscriptc .wmlsc
Save the file and restart Apache.
IIS (Internet Information Server)
On the server console, open the management console. From here, you can define
whether the MIME types will be valid for the entire server or for separate
directories. To add a MIME type to a directory, all you need to do is right
click on the directory to which you want to add the MIME type, select the HTTP
headers tag and click the File Types button at the lower right. Click New type
and supply the extension and the content type as listed above.
To add a MIME type to an entire server, right click on the server, click the
File Types button, and follow the same procedure as for adding MIME types to a
directory.
We now proceed to actual server-side scripting to generate dynamic WAP pages.
Generating dynamic WAP content
The script for generating WAP content with ASP, PHP, Perl, and JSP is given
here. In all cases except with ASP, we’ve given that part of the code that
tells your browser that WAP content is being sent to it and specify the MIME
type of the content. You can put in your actual content after this. Page(s):
1
2
|