The [] operator is like the dot only way better

The dot operator works only when the thing on the right is a bean property or map key for the thing on the left. That’s it. But the [ ] operator is a lot more powerful and flexible...

This:

${person["name"]}

Is the same as this:

${person.name}
image with no caption

The simple dot operator version works because person is a bean, and name is a property of person.

But what if person is an array?

Or what if person is a List?

Or what if name is something that can’t be expressed with the normal Java naming rules?

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.