Find out just how deep the nesting goes...

You can walk your way up the ancestor tag chain by continuing to call getParent() on whatever is returned by getParent(). Because getParent() returns either another tag (on which you can call getParent()), or null.

In a JSP

<mine:NestedLevel>
  <mine:NestedLevel>
   <mine:NestedLevel/>
  </mine:NestedLevel>
</mine:NestedLevel>

In a Classic tag handler

image with no caption

Result

image with no caption

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.