Using the dot (.) operator to access properties and map values

The first variable is either an implicit object or an attribute, and the thing to the right of the dot is either a map key (if the first variable is a map) or a bean property if the first variable is an attribute that’s a JavaBean.

  1. If the expression has a variable followed by a dot, the left-hand variable MUST be a Map or a bean.

    image with no caption

    When the variable is on the left side of the dot, it’s either a Map (something with keys) or a bean (something with properties).

    This is true regardless of whether the variable is an implicit object or an attribute.

  2. The thing to the right of the dot MUST be a Map key or a bean property.

    image with no caption

    The pageContext implicit object is a bean—it has getter methods. All other implicit objects are Maps.

    If the object is a bean but the named property doesn’t exist, then an exception is thrown.

  3. And the thing on the right must follow normal Java naming rules for identifiers.

    ${person.name}

    * Must start with a letter, _, or $.

    * After the first character, you can include numbers.

    * Can’t be a Java keyword.

Get Head First Servlets and JSP, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.