Trying to display the property of the property

We know we can do it with scripting, but can we do it with the bean standard actions? What happens if we put “dog” as the property in the <jsp:getProperty> tag?

Without standard actions (using scripting)

image with no caption

What we WANT What we GOT

image with no caption
image with no caption

You can’t say: property=“dog.name

There’s no combination of the bean standard actions that’ll work given the original servlet code, because the Dog is not an attribute! Dog is a property of the attribute, so you can display the Dog, but you can’t navigate to the name property of the Dog property of the Person attribute.

The <jsp:getProperty> lets you access only the properties of the bean attribute. There’s no capability for nested properties, where you want a property of a property, rather than a property of the attribute.

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.