Jack's Hacks
Jacky Welcome to Jack's Hacks, a monthly feature on the Openwave Developer web site to provide you, the developer, with technical tips, tricks and sample code to optimize your wireless sites.

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

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.

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

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.

Jack's Archives

 

   Copyright © 2000-2003 Openwave Systems Inc.    All Rights Reserved.