SolutionsTools & SDKSupport  



Quick Links
 
November 2002
 
 
Jack's Hack for the month of November, 2002:

User-Agent Discovery with Openwave Mobile Browser 6.x

The Openwave Mobile Browser 6.1 and higher contain support for XHTML Mobile Profile, and declare support for text/html in the HTTP_ACCEPT header. This version of the browser also contains full support for WML 1.3. This month in Jack's Hack we discuss how to detect when a device with the Openwave Mobile Browser 6.1 accesses your site, what content type should you serve it.

In order to make life easier for developers, and to accept the widest array of content that the device can actually handle, the Openwave Mobile Browser includes text/html in the accept header. To build an effective and meaningful user experience from your site, you should be aware that your webserver may recognize this accept header and return the Desktop version of your application to mobile devices. It is important to be aware of this issue and configure your applications appropriately. Use this simple guideline to decide what to deliver to the Openwave Mobile Browser 6.1 and higher.

  • If you have a mobile version of your application written in XHTML Mobile Profile, deliver it
  • If you have a mobile version of your application written in WML, but not in XHTML Mobile Profile, deliver the WML for now (but start developing XHTML Mobile Profile)
  • If you do not have a mobile version of your application yet, start developing today using XHTML Mobile Profile

To detect if your site is being visited by the Openwave Mobile Browser 6.1 or higher, you should take the following steps:

  • Look for text/vnd.wap.wml in the HTTP_ACCEPT header
  • Look for the string UP.Browser/6 in the HTTP_USER_AGENT header

Below is a code snippet on user agent detection that may assist in your accept header discovery/parsing using Java Servlets

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){

  if ((ua.indexOf("UP.Browser\/6") != -1)){
     # deliver XHTML Mobile Profile
  }
  else{
     # deliver WML
  }
}else
{
 # deliver HTML
}

For more information on XHTML Mobile Profile, and how to build applications using it, please refer to the previous "Jack's Hack" on Converting WML to XHTML. You may also find the UA Counter Tool useful in determining the frequency of visits to your site by the Openwave Mobile Browser.

 
Copyright © 2000-2008 Openwave Systems Inc.    Openwave  |  Terms & Conditions  |  Privacy Policy