arrow_back history picture_as_pdf This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ~~NOTRANS~~ ~~Title: Accessing user agent~~ 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: <file java> getLauncher().getParameter(VaadinUI.PROP_USERAGENT); </file> or <file java> getLauncher().getParameter("Web.useragent"); </file> \\ If you need more details about the browser, e.g. if it runs on a mobile device or on a table, simply call <file java> ((VaadinUI)getApplication().getLauncher().getResource()).getAgentInfo() </file> The object will be an instance of ''com.handinteractive.mobile.UAgentInfo''. The class was copied from [[http://blog.mobileesp.com/|MobileESP]] and integrated in our UI because we tried to reduce dependencies and it was only [[https://code.google.com/p/mobileesp/source/browse/Java/UAgentInfo.java|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 <file java> getLauncher().getParameter(VaadinUI.PROP_PHONE); </file> or </file java> getLauncher().getParameter("Web.mobile.phone"); </file> of <file java> getLauncher().getParameter(VaadinUI.PROP_TABLET); </file> or <file java> getLauncher().getParameter("Web.mobile.tablet"); </file> If you need access to the original HttpRequest, simply use [[jvx:common:util:httpcontext|HttpContext]] to get access: <file java> HttpContext hctxt = HttpContext.getCurrentInstance(); if (hctxt != null) { Object request = hctxt.getRequest(); if (request instanceof HttpServletRequest) { ((HttpServletRequest)request).getHeader("User-Agent"); } } </file> Be careful, it's also possible that the original request was a PortletRequest.