7

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.

asked Sep 19, 2011 at 9:57
1
  • 1
    AFAIK, 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. Commented Sep 19, 2011 at 10:02

5 Answers 5

22

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());
vegemite4me
6,9566 gold badges59 silver badges82 bronze badges
answered Nov 5, 2012 at 9:50
Sign up to request clarification or add additional context in comments.

Comments

11

Take a look at user-agent-utils.

NealeU
1,34712 silver badges24 bronze badges
answered Sep 19, 2011 at 10:00

2 Comments

User agent Utils are really useful. It returns the exact version with two lines of coding.
@coder247 - can you share the code snippet... I googled it but still was not able to find it
1

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

answered Sep 19, 2011 at 10:00

Comments

0

I recommend UA Detector at uadetector.sourceforge.net

answered Oct 20, 2013 at 12:37

Comments

0
answered Sep 19, 2011 at 10:00

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.