browser version detection from server side with java
26,885
Solution 1
Take a look at user-agent-utils
.
Solution 2
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());
Solution 3
Check the headers in the HTTP servlet request - they'll tell you. Check the "User-Agent" header.
Author by
coder247
Updated on July 25, 2020Comments
-
coder247 over 3 years
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.
-
coder247 about 12 yearsUser agent Utils are really useful. It returns the exact version with two lines of coding.
-
Varun about 11 years@coder247 - can you share the code snippet... I googled it but still was not able to find it
-
Charlie Kee over 10 yearsawesome. this is just what i need.