I'm using JSP, Servlet to develop my web application.
I want to get client information such as: operation system, browser, resolution, ... whenever a client is using my website.
I'm using JSP, Servlet to develop my web application.
I want to get client information such as: operation system, browser, resolution, ... whenever a client is using my website.
The browser sends this information in the HTTP header. See the snoop example of Tomcat for some code (online demo).
Note that this information is not reliable. Browser can and do lie about who they are and what OS they run on.
Your best bet is User-Agent header. You can get it like this in JSP or Servlet,
String userAgent = request.getHeader("User-Agent");
The header looks like this,
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.13) Gecko/2009073021 Firefox/3.0.13
It provides detailed information on browser. However, it's pretty much free format so it's very hard to decipher every single one. You just need to figure out which browsers you will support and write parser for each one. When you try to identify the version of browser, always check newer version first. For example, IE6 user-agent may contain IE5 for backward compatibility. If you check IE5 first, IE6 will be categorized as IE5 also.
You can get a full list of all user-agent values from this web site,
With User-Agent, you can tell the exact version of the browser. You can get a pretty good idea on OS but you may not be able to distinguish between different versions of the same OS, for example, Windows NT and 2000 may use same User-Agent.
There is nothing about resolution. However, you can get this with Javascript on an AJAX call.