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 9200255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:43:29+00:00 2026-06-17T22:43:29+00:00

I am trying to generate a tree structure in java to display in html.

  • 0

I am trying to generate a tree structure in java to display in html. I can get it working by producing pure html in Java, but I would prefer to keep the html for the tree components (root, branch, leaf) in tags rather for maintainability. Is there a good way to have a java string containing a custom tag (or any tag for that matter) be translated into html?

I’ve tried a few things:

-build the string in the controller then print it in the jsp (via scriptlet or EL)
The string is not translated but prints as is, i.e. displays in the browser

-build the structure in controller, pass it to a custom tag which produces the string (more custom tags)
Same problem as above. Could not get it to re-translate the body. I tried both BodyTagSupport and SimpleTagSupport

-use core tags
Structure is too complex, so this is not an option

-scriptlets
don’t play well with tags

Any ideas?

  • 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-17T22:43:31+00:00Added an answer on June 17, 2026 at 10:43 pm

    If I understand correctly, your tag generates HTML code containing another custom tag instance. So in fact, it doesn’t generate HTML, but JSP code. That’s not allowed. The JSP container won’t re-parse and interpret the code your tag generates.

    But there’s no reason you can’t call your tag methods (or your JSP tag, if implemented as a tag file) yourself to implement recursion. Here’s a simple example using a JSP tag file (tree.tag, taking a collection of nodes as parameter):

    <%@ tag %>
    <%@ attribute name="nodes" required="true" rtexprvalue="true" type="java.util.collection" %>
    <ul>
        <c:forEach var="node" items="${nodes}">
            <li><c:out value="${node.text}"/>
                <c:if test="${!empty node.subNodes}">
                    <myTags:tree nodes="${node.subNodes}">
                </c:if>
            </li>
        </c:forEach>
    <ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate a call tree for code I'm working on (I didn't
I'm trying to generate a tree structure from a table in a database. The
I'm trying to generate the following html code using cl-who: <html> <body> <div id=cnt_1></div>
I have an application storing a tree structure and is able to generate the
I'm trying to generate Java classes from several specific XSD's with xjc . Those
I am trying to generate JavaDoc comments in Eclipse for my Android Project, but
I am trying to get a Java desktop application to pull some data from
I'm trying to build a binary tree, but from some reason my code doesn't
I'm currently trying to recursively loop through a tree structure and serialize it to
I'm creating a tree-structure of categories with parentid's which can be called from children

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.