coder247
coder247

Reputation: 2943

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.

Upvotes: 7

Views: 27421

Answers (5)

Paul Grime
Paul Grime

Reputation: 15104

Use Spring Mobile Device Module?

This can use either the LiteDeviceResolver or the WurflDeviceResolver.

Upvotes: 0

NPE
NPE

Reputation: 500883

Take a look at user-agent-utils.

Upvotes: 11

coder247
coder247

Reputation: 2943

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());

Upvotes: 22

Alireza Fattahi
Alireza Fattahi

Reputation: 45613

I recommend UA Detector at uadetector.sourceforge.net

Upvotes: 0

duffymo
duffymo

Reputation: 309008

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

Upvotes: 1

Related Questions