0

`Hi,

I am trying to get the user's browser information in my servlet filter. I used a simple code, see below.

String userAgent = request.getHeader("User-Agent");

User was using Google chrome, and what the above code printed is below.

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36

It printed the names of all the major browsers instead of getting the once the app is running. what is wrong here?

PeakGen
  • 21,894
  • 86
  • 261
  • 463
  • 6
    This is Chrome's user agent string. – xehpuk May 08 '15 at 07:46
  • On this [site](http://www.useragentstring.com/pages/Chrome/) is a list of all user agent strings used by the different browsers. – Thomas Schmidt May 08 '15 at 07:53
  • see http://stackoverflow.com/questions/1326928/how-can-i-get-client-infomation-such-as-os-and-browser for more help – MaVRoSCy May 08 '15 at 08:10
  • Most modern browsers [spoof their identification](https://en.wikipedia.org/wiki/User_agent#User_agent_spoofing) to let a server think that it is compatible to render the complex content. It's a long story. See this [answer](http://stackoverflow.com/a/1114297/1122665) for more information. – Wenhao Ji Aug 10 '15 at 04:43

1 Answers1

0

Nothing is wrong here.

For example let us consider the returned string is

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36

Then the explanation is

ChromeChrome 41.0.2228.0

Mozilla ==> 

MozillaProductSlice. Claims to be a Mozilla based user agent, which is only true for Gecko browsers like Firefox and Netscape. For all other user agents it means 'Mozilla-compatible'. In modern browsers, this is only used for historical reasons. It has no real meaning anymore

5.0 ==> Mozilla version

Windows NT 6.1  ==> Operating System Windows 7 

AppleWebKit  ==> The Web Kit provides a set of core classes to display web content in windows

537.36       ==> Web Kit build
KHTML        ==> Open Source HTML layout engine developed by the KDE project
like Gecko   ==> like Gecko...
Chrome  Name ==> Chrome
41.0.2228.0  ==> Chrome version
Safari       ==> Based on Safari
537.36       ==> Safari build

Description:    Free open-source web browser developed by Google. 
Chromium is the name of the open source project behind Google Chrome, released under the BSD license.

You can find more information in below link

http://www.useragentstring.com/pages/Chrome/

click on each link on the page to get more info

Raj
  • 1,945
  • 20
  • 40