Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8961551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:55:12+00:00 2026-06-15T15:55:12+00:00

I am working on a custom tag that processes a hierarchical Bean. The bean

  • 0

I am working on a custom tag that processes a hierarchical Bean. The bean looks something like this:

public class HierarchyBean {
    public List<HierarchyBean> children;
    public List<SomeOtherBean> someListOfBeans;
    // getters/setters for Bean
}

Now I want to make a tag such that I could do this in my JSP:

<ul>
<cust:hierarchy hierarchyBean="${root}">
    <li>${subBean}</li>
</cust:hierarchy>
</ul>

with the custom tag looking something like this:

<%@ tag body-content="scriptless" %>

<%@ attribute name="hierarchyBean" required="true" rtexprvalue="true" type="com.publix.webforms3.survey.domain.Element" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"  %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="cust" tagdir="/WEB-INF/tags/hierarchy" %>

<c:forEach items="${someListOfBeans}" var="bean">
    <c:set var="subBean" value="${bean}" scope="page" />
    <jsp:doBody />
</forEach>
<ul>
<c:forEach items="${children}" var="child">
<cust:hierarchy hierarchyBean="${root}">
    <li>${subBean}</li>
</cust:hierarchy>
</c:forEach>
</ul>

So, first, let me appologize if there are sloppy mistakes in the above code…my actual project is quite complex, and I tried to hand-type a more simple example.

Second, I’d like to point out the recursive nature of the tag IS working. What is not working is the setting of “subBean”. I tried both with and without the c:set, but in my calling JSP code it appears that subBean is not carried out of the tag back to the body within the tag.

I do know that the jsp:doBody has some attributes, namely var and varReader, but it doesn’t seem like either is doing what I need.

Is this possible, and if so, what am I doing wrong here that is making it not work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:55:14+00:00Added an answer on June 15, 2026 at 3:55 pm

    You should add the following to your tag:

    <%@ variable name-given="subBean" scope="NESTED" %>
    

    This will cause the container to save the value of the subBean attribute in the page (if any), then invoke your tag and make the subBean variable defined by the tag available to the body of the tag, then restore the saved value of the subBean attribute.

    More details here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working custom UserNamePasswordValidator that calls into my Oracle DB. This class
I'm working on an app that uses a custom class with other custom classes
I have a nicely working custom CursorAdapter with customized ListView. This view allows the
I'm working on a custom user control that essentially displays a name value pair
I'm working up a custom Xcode template, and I'd like to change the way
I'm attempting to create a custom jsp tag. Everything is working fine, except for
I'm working with a publishing system that uses custom tags. These are interpreted on
I'm trying to create a custom AccordionItem that can take the tag property value
I added a UITableView as a subview to a custom UIView class I'm working
I am working on an app that implements a custom ListView that contains images.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.