I saw many posts related to the browser detection, User agent detection etc...I want to detect the version from server side and send appropriate data based on that.
I know browsers can mimic version with tools, but that doesn't matter for me.
I need the java solution for the exact version detection.
In the browser's toolbar, click on “Help"or the Settings icon. Click the menu option that begins “About” and you'll see what type and version of browser you are using.
Here is the code explaining how to do it using user-agent-utils:
String userAgent = req.getHeader("user-agent");
UserAgent ua = UserAgent.parseUserAgentString(userAgent);
Version browserVersion = ua.getBrowserVersion();
String browserName = ua.getBrowser().toString();
int majVersion = Integer.parseInt(browserVersion.getMajorVersion());
Take a look at user-agent-utils
.
Check the headers in the HTTP servlet request - they'll tell you. Check the "User-Agent" header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With