Web.xml Configuration - Version 3
Unlike previous version of the Java API, much of the 51Degrees configuration is now done from web.xml. This guide will cover parameters to fine tune 51Degrees with and setup configuration so the server side components will work.
51Degrees web.xml Parameters
The following table describes the available parameters and their uses:
Parameter | Type | Default | Description |
---|---|---|---|
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. |
Setup Configuration
The following xml is needed so the 51Degrees API can listen for the necessary events to provide detection and other services. 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>