views:

122

answers:

1

In order to achieve browser compatibility in application I am in need of Java class/Bean/Jar which will return the following information current browser of user its Name,version and also the OS of the user. Any thought on this will be really helpful, this should work well in latest versions of all the Modern Browsers such Chrome, Safari and Opera. How can I solve this the best?

A: 

Since the user agent data is extremely sensitive to changes and you'd like to delegate the maintenance of the data to a 3rd party, consider to use a public webservice like http://user-agent-string.info. They also have a Java example for the XML-RPC service.

You can obtain the user agent of the current request using HttpServletRequest#getHeader().

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

Use that as parameter for the webservice.


That said, if you actually have compatibility problems in the HTML/CSS/MSIE area, you should really consider conditional comments. If in JS area, use feature detection. You should not rely on the user agent and certainly not in the server side. Consider posting a new question about the problem for which you thought that sniffing the user agent in the server side is the solution. You'll get much better suited answers.

BalusC
@BalusC Thanks a lot, that's really helpful. My apologies for late reply.
An Object