A Tag can call its Parent Tag

Both SimpleTag and Tag have a getParent() method. The getParent() in Tag returns a Tag, but the getParent() in SimpleTag returns an instance of JspTag. We’ll see the implications of those return types in a minute.

image with no caption

A nested tag can access its parent (enclosing) tag

image with no caption

Getting the parent tag in a Classic tag handler

image with no caption

Getting the parent tag in a Simple tag handler

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.