Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

browser version detection from server side with java

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.

like image 981
coder247 Avatar asked Sep 19 '11 09:09

coder247


People also ask

How do I find my browser version?

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.


3 Answers

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());
like image 66
coder247 Avatar answered Nov 29 '22 00:11

coder247


Take a look at user-agent-utils.

like image 33
NPE Avatar answered Nov 29 '22 00:11

NPE


Check the headers in the HTTP servlet request - they'll tell you. Check the "User-Agent" header.

like image 37
duffymo Avatar answered Nov 29 '22 00:11

duffymo