Genie 7110 manual Genie Application Style Guide

Models: 7110

1 84
Download 84 pages 46.18 Kb
Page 78
Image 78
74 Genie Application Style Guide

A Identifying the Browser

Java

public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{

String acc = req.getHeader("Accept"); String ua = req.getHeader("User-Agent"); ServletOutputStream out = res.getOutputStream();

if (acc.indexOf("wml") != -1){ deliver wml

}

else { res.setHeader(res.SC_MOVED_TEMPORARILY); res.setHeader("Location", "http://mysite.com/index.html");

}

ASP

<%response.buffer="true" Dim accstring

Dim uastring

uastring = request.ServerVariables("HTTP_USER_AGENT") accstring = request.ServerVariables("HTTP_ACCEPT")

If (InStr(accstring,"wml")) Then Deliver wml

Else

Response.Redirect("/index.html")

In all of these cases, it has been established that the client sends WML in the

HTTP_ACCEPT header and can thus assume that WML should be delivered. If WML is not found in the HTTP_ACCEPT list, HTML is delivered. This ensures that HTML is delivered to web browsers and to spiders (crawlers, site indexers).

Once a WML device is found, it is possible to discriminate further to see exactly which device is accessing the site. Three possibilities are accounted for in this code: (1) the UP.Browser from Openwave, (2) the Mitsubishi Trium (3) any other device (including the Nokia browser).

Perl

if ($ua =~"UP.B" $ua =~"UP/"){

Print "Location: /opwv/index.wml \n\n";

}

elseif($ua =~"Mitsu"){

print "Location: /mitsu/index.wml \n\n";

}

else{

print "Location: /nokia/index.wml \n\n";

};

74 Genie Application Style Guide

February 2001

Page 78
Image 78
Genie 7110 manual Genie Application Style Guide