How do I identify the device (browser) the request is coming from? - 11.25.00

Russell Quong



public void doGet (HttpServletRequest req, HttpServletResponse resp) .... {
String browser = req.getHeader("User-Agent");
On Linux I get something like:
Mozilla/4.73 [en] (X11; U; Linux 2.2.17 i686)

You'll see "MSIE" somewhere for internet explorer. Surprisingly, on both IE (on NT) and Netscape return "Mozilla" as part of the response.

[It's not surprising, it's just stupid. :-) The reason IE pretends to be Mozilla goes back to the days when Netscape (aka Mozilla) was the only browser that supported certain features, e.g. Tables. Certain CGI scripts would check the user-agent header, and only output tables if the UA contained the string "Mozilla." Otherwise, they would output a lame < PRE > version, or nothing at all. Naturally, the authors of IE wanted their browser to show these tables, so they *had* to lie.

The solution would have been if the Netscape browser sent a different, capabilities-oriented header (e.g. "Accepts: Tables") but Netscape was a hastily written, poorly-though-out piece of junk. IMHO. :-)

Initiatives like CC/PP and UAProf are attempting to fix the problem for both Web and WAP browsers but their acceptance remains to be seen.