How do I tell what browser is hitting a servlet?
Author: Deron Eriksson
Description: This Java servlet tutorial describes how to use a request header's user-agent to tell what browser is hitting a servlet.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1 || Tomcat 5.5.20
(Continued from page 1)
Notice the 'user-agent' value. It tells us that the browser hitting the servletW is IE 7 and rather crypically that the platform is Windows XP.
If we hit our servlet in Firefox 2, we see the following:
Notice that the 'user-agent' value tells us that the version of the browser is Firefox 22.214.171.124 and that once again the platform is Windows XP.
As you can see, it's easy to view the user-agent string, which can tell us information about the browser hitting our servlet and the platform on which the browser is running. However, user-agent strings can literally come in endless varieties, so a highly detailed analysis of the user-agent strings can be a challenge.