Skip navigation.
Downloads | Product Documentation | Support

MobileAware Interaction Server User Guide

# Appendix B - MobileAware Delivery Context API

# Accessing MobileAware Interaction Server Attributes

To access the MobileAware proprietary database set, you must use the MobileAware Interaction Server Delivery Context API. The following code block shows how this is done.

>     <%@ taglib uri="mmJSPtaglib" prefix="mm" %>

>     <mm:page content="false">

>     <%@ page import="com.mobileaware.deliverycontext.*" %>

>     <%

>      DeliveryContext dc = null;

>      String deviceName = null;

>      String imgList = null;

>     %>

>     <html>

>     <head>

>        <title>MA Delivery Context API</title>

>        <mm:structure id="st_101" where="IsMenuDriven">

>           <mm:group-ref idref="gp_101" depth="flat" type="normal" display="all"/>

>        </mm:structure>

>     </head>

>     <body>

>     <%

>     try {

>      dc = DeliveryContextFactory.getDeliveryContext(request);

>     } catch(Exception e) {

>      out.println("<p>Problem creating delivery context.</p>");

>     }

>     %>

>     <mm:group id="gp_101" title="Details">

>     <%

>      try{

>       deviceName= dc.getAttribute("DeviceName");

>       imgList = dc.getAttribute("ImgTypePref");

>      }

>      catch(Exception e){System.out.println(e);}

>     %>

>       <p>I am a <%=deviceName%>.</p>

>       <p>I accept images that are: <%=imgList%></p>

>     </mm:group>

>     </body>

>     </html>

>     </mm:page>

The results when accessing MobileAware attributes of a WML emulator are shown below.

Figure 1 Results

Image Courtesy of Openwave Systems Inc

## Available Public Methods

There are a number of public methods that can be used to access the MobileAware Device Database device attributes.

Table 1 Public Methods

API Call | Attribute DataType | Java Type Returned
--- | --- | ---
getIntAttribute() | Integer | int
getLiteralAttribute() | Literal | String
getURIAttribute() | URI | String
getRationalAttribute() | Rational | double
getDimensionAttribute() | Dimension | Dimension
getSequenceAttribute() | Sequence | List
GetBagAttribute() | Bag | Set
getAttribute() | Integer | String
getAttribute() | Literal | String
getAttribute() | Boolean | String
getAttribute() | URI | String
getAttribute() | Rational | String
getAttribute() | Dimension | String
getAttribute() | Sequence | String
getAttribute() | Bag | String

The methods listed here have either one or two parameters: an attribute name or an attribute name and a default value to return in the event that no value is available.

### Example:

>     GetIntAttributes("MaxWapDeckSize");

>     GetIntAttribute("MaxWapDeckSize", 1400);

## Handling Exceptions

There are four exceptions that can be thrown when using the methods listed in the table above. It is considered good practice to place try - catch blocks around these method calls.

### DeliveryContextRuntimeException

Thrown when an unexpected condition causes DeliveryContext creation or method to fail. The exception message describes the problem, such as "invalid ServletRequest Object".

### InvalidAttributeTypeException

Thrown when a type-specific method is called on an attribute of the wrong type. For example, using getBooleanAttribute() to obtain a String value.

### NoSuchAttributeException

Thrown when an attribute name is requested and that attribute does not exist. This is different from the attribute existing and not having a value defined for the requesting device.

### AttributeValueUndefinedException

Thrown when an attribute name is requested but the attribute value does not exist.

Note: The MobileAware Delivery Context API is able to access both the CC/PP attrbutes and the proprietary set.