Software Sue

Link to Simply Sue
Link to Sustainability Sue
location: software/markup/wap/serving Skip navigation : Home  

Serving WML Pages


MIME types tell browsers what sort of pages they are receiving.

Most servers can be configured to serve wml files. These include UNIX, NT, NCSA, Apache. Change the MIME type file to include relevant extensions:

Official MIME type Doc. type Extension
text/vnd.wap.wml WML document .wml
image/vnd.wap.wbmp Wireless Bitmap Image .wbmp
text/vnd.wap.wmlscript WMLScript .wmls
application/vnd.wap.wmlc Compiled WML document .wmlc
application/vnd.wap.wmlscriptcCompiled WML Script .wmlsc

Apache

For example, in Apache type the following in the srm.conf file (in /etc/httpd/conf), or .htaccess files in the directory/ies that you require, save and restart Apache:

# 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

IIS

Open the management console from the Microsoft IIS server console. Define the MIME types to be valid either for the entire server or for separate directories. To add a MIME type to a directory, right click on the directory in 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 instructions above. There's an HTTP header tab on the Management Console of Microsoft Servers.

Different Browsers

To use one URI for a site, both WAP and HTML, you must use a server parsed language in your pages, such as ASP, PHP or SSI. You then need to know what browser the client is using - which is returned by the browser so that the server can deliver the document back.

Unfortunately, each browser uses different identification codes, so the server program has to know them all, and needs to be updated for each new browser.

ASP

The following code is by Robin van Emden (rave@dataweb.nl). It redirects the browser to /index.html or /index.wml as is neccessary.

   <% Response.Buffer = TRUE
   Dim IsWap
   httpAccept = LCase(Request.ServerVariables("HTTP_ACCEPT"))
   if Instr(httpAccept,"wap") then
   IsWap=1
   Else Response.Redirect "/index.html" : Response.Flush : Response.End
   End if %>
   <%Response.ContentType = "text/vnd.wap.wml"%>
   <?xml version="1.0"?>
   <%Response.Flush%>
   <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
      "http://www.wapforum.org/DTD/wml_1.1.xml">
   <wml>
   <card id="redirect">
   <onevent type="onenterforward">
   <go href="/index.wml"/>
   </onevent>
   <p> <a href="/index.wml">enter</a> </p>
   </card>
   </wml>
   <%Response.Flush:Response.End%>

PHP

WapDesign ORG U.K. got the code below from http://wap.colorline.no/wap-faq/ (Robert Whitinger's (robert@wapsight.com) (site couldn't be found last time I tried) code submitted to the PHP mailing list, with several additions for browser ID string from Don Amaro's (donamaro.concepcion@nl.unisys.com)). Code may be freely used with attribution.

<?
  // Because this script sends out HTTP header information,
  // the first characters in the file must be the
  $htmlredirect = "/html/my_htmlpage.html";
  // relative URL to your HTML file

  $wmlredirect = "http://wap.mysite.com/wml/my_wmldeck.wml";
  // ABSOLUTE URL to your WML file

  if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0) {
  // Check whether the browser/gateway says it accepts WML.

    $br = "WML";
    }
    else {
      $browser=substr(trim($HTTP_USER_AGENT),0,4);
  if(
    $browser=="Noki" || // Nokia phones and emulators
    $browser=="Eric" || // Ericsson WAP phones and emulators
    $browser=="WapI" || // Ericsson WapIDE 2.0
    $browser=="MC21" || // Ericsson MC218
    $browser=="AUR " || // Ericsson R320
    $browser=="R380" || // Ericsson R380
    $browser=="UP.B" || // UP.Browser
    $browser=="WinW" || // WinWAP browser
    $browser=="UPG1" || // UP.SDK 4.0
    $browser=="upsi" || // another kind of UP.Browser ??
    $browser=="QWAP" || // unknown QWAPPER browser
    $browser=="Jigs" || // unknown JigSaw browser
    $browser=="Java" || // unknown Java based browser
    $browser=="Alca" || // unknown Alcatel-BE3 browser (UP based?)
    $browser=="MITS" || // unknown Mitsubishi browser
    $browser=="MOT-" || // unknown browser (UP based?)
    $browser=="My S" || // unknown Ericsson devkit browser ?
    $browser=="WAPJ" || // Virtual WAPJAG www.wapjag.de
    $browser=="fetc" || // fetchpage.cgi Perl script from www.wapcab.de
    $browser=="ALAV" || // yet another unknown UP based browser ?
    $browser=="Wapa")   // another unknown browser ("Wapalyzer"?)
      {
      $br = "WML";
    }
    else {
      $br = "HTML";
      }
    }

  if($br == "WML") {
  header("302 Moved Temporarily");
    // Force the browser to load the WML file instead
    header("Location: ".$wmlredirect);
    exit;
    }
  else {
  header("302 Moved Temporarily");
  // Force the browser to load the HTML file instead
  header("Location: ".$htmlredirect);
  exit;
  }
?<

SSI

This code from WapDesign ORG U.K. saves a file name (either wap.wml or index.html) into the variable 'page' depending on the browser type. Code may be freely used with attribution. For an SSI script, you have to pass a variable to a CGI script. You will need to write the CGI script.

<!--#if expr="${HTTP_USER_AGENT} = /Noki/" -->
<!--#set var="page" value"wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /Eric/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /WapI/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /MC21/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /AUR /" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /R380/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /UP.B/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /WinW/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /UPG1/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /upsi/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /QWAP/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /Jigs/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /Java/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /Alca/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /MITS/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /MOT-/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /My S/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /WAPJ/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /fetc/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /ALAV/" -->
<!--#set var="page" value="wap.wml" -->
<!--#elif expr="${HTTP_USER_AGENT} = /Wapa/" -->
<!--#else -->
<!--#set var="page" value="index.html" -->
<!--#endif -->