␡
- Creating a Wireless Web Application
- A Brief Introduction to WML
- Detecting Wireless Clients in a JSP or Servlet
< Back
Page 3 of 3
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 }
< Back
Page 3 of 3