Select language:

User Agent Service


User agents are applications, which are used to browse the Web, such as Web browsers, search engine spiders, as well as accessibility tools, such as screen readers and Braille browsers.

When a browser connects to a server, it passes the information regarding the brand and version of the browser, and the operating system in which the browser is running, in the User-Agent field contained in the HTTP Request header. For example, Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; ).

You can use the User Agent service of the Portal Runtime to access the user agent information, as described below.


To use the User Agent Service, add a sharing reference entry to the deployment descriptor (file portalapp.xml ) in the <application-config> section.

<property name="SharingReference" value=""/>


Obtaining a User Agent Service

Obtain a reference to the IUserAgentService interface, as follows:

IUserAgentService userAgentService =(IUserAgentService) PortalRuntime.getRuntimeResources().getService("");

Obtaining a User Agent Object

Obtain a user agent object from the HttpServletRequest object, as follows:

HttpServletRequest sRequest = request.getServletRequest();
String userAgentName = sRequest.getHeader("User-Agent");
//With this information call getUserAgent( to get the user agent object of type IUserAgent:
IUserAgent userAgent =userAgentService.getUserAgent(sRequest.getHeader(userAgentName));

Obtaining the User Agent Family

Obtain the user agent family information by calling the getUserAgentFamily() method, as follows:

IUserAgentFamily userAgentFamily =userAgentService.getUserAgentFamily();
/*  From this object you get an enumeration of all user agent sets of
type IUserAgentSet that matches the IUserAgent object   */
Enumeration enum = userAgentFamily.findUserAgentSets(userAgent);
More Information

For more information about the IUserAgentService methods, refer to the Enterprise Portal Javadocs at