I would like to know how to print the browser the client is using and the OS if using jsp. Some people have suggested using ${header["user-agent"]}
however, this command returns a lot of information and I would just like the browser and OS.
I would like to know how to print the browser the client is using and the OS if using jsp. Some people have suggested using ${header["user-agent"]}
however, this command returns a lot of information and I would just like the browser and OS.
Take a look at user-agent-utils , with this lib you can easily extract the information which you need, for example:
String userAgentStr = request.getHeader("User-Agent");
UserAgent userAgent = UserAgent.parseUserAgentString(userAgentStr);
And in the UserAgent object you have methods like getOperatingSystem()
and getBrowser()
. Javadoc here.