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

0

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.

    
asked by anonymous 21.11.2016 / 01:29

1 answer

0

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.

    
21.11.2016 / 12:00