File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Getting browser type and version? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting browser type and version?" Watch "Getting browser type and version?" New topic

Getting browser type and version?

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
I want to get browser type and version from the request and i had used request .getHeader("User_Agent") but im getting
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) .but im using MSIE.. and even tried not installing the mozilla also but im getting the same value....please conclude me how to get the type and version of browser

Creativity is nothing but Breaking Rules
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

All the user_agent header does is reports what the browser tells it. IE tells you just what you are seeing. See this for more about IE user agent strings.

NB: you need to be aware there are browsers that will spoof this to avoid browser compatability restrictions. For example you can get Opera to report itself as IE.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

Why do you need this information? If it's to conditionals JavaScript, there are better techniques than browser detection.

[Asking smart questions] [About Bear] [Books by Bear]
It is sorta covered in the JavaRanch Style Guide.
subject: Getting browser type and version?
It's not a secret anymore!