![]() | 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. |
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:
text/vnd.wap.wml
in the HTTP_ACCEPT
header
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-2003 Openwave Systems Inc. All Rights Reserved. |