Sunday, November 08, 2009  
Google
Web pcquest.com

CIOL Network sites

Search by Issue | Sitemap | Advanced Search

• For most updated version of DQ TOP 20 issue, visit dqindia.com • Ad : Play and Plug ERP by IBM


 
    Enterprise Solutions
    Hands On
    ITstrategy

    Developer

    Tech Forum

    SMB Forum

    Trends

    Shootout

    Reviews
    Editorials
    Linux and Open Source
    Technology
    Extraedge

    IT Careers

    Vertical Focus

Subscribe to Print magazine.


now!


Newsletter

 

Home > Technology > Advanced WAP Programming


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.

WAP with ASP

Response.ContentType = "text/vnd.wap.wml"

Response.Write"Welcome Visitors"

Response.Write " WAP is good "

WAP with PHP

PHP is so flexible that one HTML document containing a PHP script can be used for both HTML and WML compatible browsers. The PHP source code is invisible to the client, just like ASP, and it’s up to you to either output HTML code or WML. However, be extra careful here, as some built-in features of PHP output HTML by default, typically error messages, which your WML micro-browser won’t understand.

For example,

header("Content-type: text/vnd.wap.wml");

echo("\n");

echo("\n\n");     

?>

… Put your content here…



Using Perl


Page(s)   1   2   

End of the article

Related CIOL Network links   External links  

None

 

none



Read Previous Technology...

   




Untitled Document



ZTE:Leading CDMA Technology


Extraordinary Networks:Freedom of Choice





Previous Stories

Communicate Anywhere, Any Way

Inside the Pentium 4

The Battle over DeCSS

Message boards

Discuss this and many other IT topics at the
CIOL message board






   
 

 
 

Magazine Subscription | RQS | Contact Us | Team PCQuest | Advertising - Print | jobs@cybermedia