Home > Articles > Programming > Java

📄 Contents

  1. Creating a Wireless Web Application
  2. A Brief Introduction to WML
  3. Detecting Wireless Clients in a JSP or Servlet
  • Print
  • + Share This

Detecting Wireless Clients in a JSP or Servlet

There is no reason why you can't write a JSP or servlet that services requests from wireless phones and Web browsers at the same time, especially when you are handling form input. When you send a response back, of course, you want to know whether you should send HTML or WML. When the browser or the phone makes a request, it passes the Web server a list of the kinds of content it will accept. You can retrieve the list by making the following method call:

String accept = request.getHeader(“Accept”);

For a wireless client, you should see text/vnd.wap.wml somewhere in the accept string. You can test for it this way:

if (accept.indexOf(“text/vnd.wap.wml”) >= 0)
{
    // handle a wireless client
}
else
{
    // handle a regular web client
}
  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.