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.
-
1AFAIK, the only way to detect browser version is by inspecting the "headers". Logically it makes sense also, as the server can not go to each "client" and find out information about it - it has to rely on the information provided by the client when the client comes to browser.Manish– Manish2011年09月19日 10:02:42 +00:00Commented Sep 19, 2011 at 10:02
5 Answers 5
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());
Comments
Take a look at user-agent-utils.
Check the headers in the HTTP servlet request - they'll tell you. Check the "User-Agent" header.
Comments
I recommend UA Detector at uadetector.sourceforge.net
Comments
Use Spring Mobile Device Module?
This can use either the LiteDeviceResolver or the WurflDeviceResolver.