• About Us
  • Blog
  • Basket
  • Account
  • Sign In
  •  

Java API

Web.xml Configuration

The Java Servlet is configured via the Web.xml settings. This guide covers the available configuration parameters and values.

51Degrees web.xml Parameters

The following table describes the available parameters and their uses:

ParameterTypeDefaultDescription
MEMORY_MODE boolean false True to load the device database into memory to improve performance at the expense of memory usage.
BINARY_FILE_PATH String null The file name of the device data that should be used. This can either be full path or a filename in the WEB-INF folder. Updates (if enabled) will be written to this location, so this value does not always have to be pointing to an existing file. If no value is supplied, or there is no data at the path the embedded Lite data will be used.
IMAGE_MAX_WIDTH int 0 Controls the maximum width an image can be resized to. This can be used to control server load if many images are being processed. If 0 this property will be ignored.
IMAGE_MAX_HEIGHT int 0 Controls the maximum height an image can be resized to. This can be used to control server load if many images are being processed. If 0 this property will be ignored.
IMAGE_FACTOR int 1 Sets a factor images dimensions must have. Image sizes are rounded down to nearest multiple. This can be used to control server load if many images are being processed.
IMAGE_WIDTH_PARAM String width Specifies what the width parameter should be for an optimised image url.
IMAGE_HEIGHT_PARAM String height Specifies what the height parameter should be for an optimised image url.

Configuring Listeners

The following XML settings should be added if you want the 51Degrees listeners: device data automatic updates and image optimiser requests. For detailed information on web.xml and their elements, see the Oracle web.xml guide for Web Logic or the Java Servlet Specification.

<listener>
  <listener-class>fiftyone.mobile.detection.webapp.FiftyOneDegreesListener</listener-class>
</listener>
<filter>
  <display-name>FiftyOneDegreesFilter</display-name>
  <filter-name>FiftyOneDegreesFilter</filter-name>
  <filter-class>fiftyone.mobile.detection.webapp.FiftyOneDegreesFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>FiftyOneDegreesFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
  <description>51Degrees Servlet</description>
  <display-name>FiftyOneDegreesServlet</display-name>
  <servlet-name>FiftyOneDegreesServlet</servlet-name>
  <servlet-class>fiftyone.mobile.detection.webapp.FiftyOneDegreesServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>FiftyOneDegreesServlet</servlet-name>
  <url-pattern>/51D/*</url-pattern>
</servlet-mapping>