How to print the Browser or OS name on a JSP - Java Web

Asked

Viewed 208 times

0

would like to know how to print the browser the client is using and if OS using jsp. Some people suggested using ${header["user-agent"]} however, this command returns various information and I would like only the browser and the OS.

1 answer

0


Take a look at user-agent-utils, with this lib you can easily extract the information 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.