Simply WURFL
WURFL?! Yes, another acronym:
Wireless Universal Resource FiLe
The WURFL website expands on this:
"You can think of the WURFL as a global database of all devices and their capabilities."
Such a database is especially useful in the current mobile device
landscape where a vast array of HTML/WML/Flash/AJAX features are implemented
differently (or not at all.) In essence, WURFL makes it easier for you to improve the web experience you offer people when they are on the move.
WURFL is the product of much diligence and attention to detail by Luca Passani and many contributors of device information. As an added bonus it is open and free for anyone to use. This is in the best interests of mobile device users everywhere of course! Luckily for us the WURFL project goes all the way and provides a Java API. To get started with WURFL you first need to ensure your ZXTM has working Java support and then download the following items.
Upload the files specified using the Calalogs > Java UI page on your ZXTM. Note that the wurfl-latest.zip can be uploaded as-is, but you can choose to unzip it and upload the wurfl.xml file. Now you're all set to experiment with the following examples. The first sample servlet is a very simple use-case of WURFL, useful as a base for your own servlet or for debugging. The intention is for it to introduce the WURFL API as it fits within the framework of Zeus Java Extensions. WURFL is typically configured using the ConfigListener model, but we're not TomCat and don't go as far as implementing all the nuts and bolts required by full web applications. Our WURFL servlet must perform the required initialisation itself, so I've implemented an init method that sets up a WURFLManager. As much work as possible is done at servlet initialisation time. Then all the doGet method needs to do is check the request against the pre-initialised WURFLManager. You can download the code or the compiled class for this servlet. To compile the code yourself execute the following javac command. This example is given for compiling on the ZXTM host system after all the .jar files mentioned above have been uploaded to your ZXTM, you can also compile the servlet on another machine as outlined in our Java Devlopment Guide. javac -cp "$ZEUSHOME/zxtm/lib/*:$ZEUSHOME/zxtm/conf/jars/wurfl-1.0.jar" \ ZeusWURFLInfoServlet.java To get the servlet working follow these steps:
The result should be a page showing some general information about your browser at the top followed by the full table of WURFL capabilities and their values. The following screenshots show the top part of the output using a few browsers available in the Zeus office. Firefox on Ubuntu Linux
Opera on HTC S710
IE on HTC S710
Safari on iPhone
This is neat and all as a demo, but not particularly useful. What we really want is a module that can export capabilities so that they can be used by TrafficScript and other extensions. We also don't want to specifically be a doGet processor, so we'll modify the servlet along the lines described in the Writing TrafficScript functions in Java article. There are a lot of capabilities covered by WURFL, the tables in the above screenshots go on for several pages - more than 500 capabilities in all. So we'll make it possible for TrafficScript to specify what capability fields it wants. This gives us a servlet that could be used from TrafficScript using the following function. sub checkWURFL() { $ua = http.getHeader( "User-Agent" ); if (!string.length($ua)) return; $markup = data.get("WURFL" . $ua . "preferred_markup"); $datarate = data.get("WURFL" . $ua . "max_data_rate"); if (string.length($markup)) { log.info("Returning cached values for User-Agent: " . $datarate . ", " . $markup); $1 = $markup; $2 = $datarate; return; } # no cached values for the UA, so run it through WURFL java.run( "ZeusWURFLServlet", "max_data_rate", "preferred_markup" ); $markup = connection.data.get("preferred_markup"); $datarate = connection.data.get("max_data_rate"); data.set("WURFL" . $ua . "preferred_markup", $markup); data.set("WURFL" . $ua . "max_data_rate", $datarate); log.info("Returning fresh WURFL values for User-Agent: " . $datarate . ", " . $markup); $1 = $markup; $2 = $datarate; return; } # simple case to test the checkWURFL function checkWURFL(); http.sendResponse("200", "text/html", "<html><head><title>WURFUL</title></head><body>" . "<h1>Max Data Rate: " . $2 . "kbps</h1>" . "<h1>Preferred Markup: " . $1 . "</h1></body></html>", ""); The corresponding Java code and .jar file are available for you to download. Rather than the doGet method implemented in the ZeusWURFLInfoServlet we now have a simpler service method. public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String[] args = (String[])request.getAttribute( "args" ); if (args == null || args.length == 0) { throw new ServletException("error: no arguments supplied"); } Device device = manager.getDeviceForRequest(request); Map capabilities = device.getCapabilities(); for (int i = 0; i < args.length; ++i) { String cap = (String)capabilities.get(args[i]); if (cap == null) { log("no capability found matching: " + args[i]); } else { ((ZXTMServletRequest)request).setConnectionData( args[i], cap ); } } } Note that for this implementation I've included another class that properly directs org.apache.commons.logging messages to the ZXTM Event Log properly. The logging code is documented here, you can also download ZeusServletLogger.class here or from that page. The commands used to build the jar file on my ZXTM host machine follow. javac -cp "$ZEUSHOME/zxtm/lib/*:$ZEUSHOME/zxtm/conf/jars/wurfl-1.0.jar" \ ZeusWURFLServlet.java jar -cvf ZeusWURFLServlet.jar ZeusWURFLServlet.class ZeusServletLogger.class There is much more you could do with the WURFL Java Extension provided in this article. Think of it as a starting point for developing your own solutions to improve the web browsing experience of your mobile users. A few examples:
Up to date documentation on all the WURFL capabilities can be found on the WURFL website. Any of these values can also be passed on to your backend nodes of course. You could add special headers containing the values, a cookie, or a URL argument. You could also cache browser capabilities uniquely to each device with cookies or another method of session tracking, rather than cache the capabilities based solely on the user agent. Then you could offer users the ability to override special mobile device modes. We would love to hear your ideas and learn how we can help you in this exciting area - the opportunities are practically limitless. |
Recently...
Other Resources
|

WURFL?! Yes, another acronym:




