Accessing User Agent

This is an old revision of the document!

Sometimes it's useful to know the browser name which runs the vaadin application. It could be useful for showing custom controls or creating responsive layouts.

We have different options to get the name of the browser (= user agent). The first one is the recommended option. Simply use your launcher to get the information:




If you need more details about the browser, e.g. if it runs on a mobile device or on a table, simply call


The object will be an instance of The class was copied from MobileESP and integrated in our UI because we tried to reduce dependencies and it was only one single file.

The class has methods like detectIpad, detectIphone, detectSmartphone but also detectSonyPlayStation or detectXbox.

If you want to know if the application runs on a tabled or smartphone, simply check


or </file java> getLauncher().getParameter(“”); </file> of




If you need access to the original HttpRequest, simply use HttpContext to get access:

HttpContext hctxt = HttpContext.getCurrentInstance();
if (hctxt != null)
    Object request = hctxt.getRequest();
    if (request instanceof HttpServletRequest)

Be careful, it's also possible that the original request was a PortletRequest.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information