O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required