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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:30:02+00:00 2026-05-28T13:30:02+00:00

I have to display a list from the database column titled Region …..for every

  • 0

I have to display a list from the database column titled “Region” …..for every item in that list, if, it contains a child value(Division), it must show something like this,

1 NorthEast Division1 | Division2

2 Midwest Division1 | Division2 | Division3

3 South Division1
….etc

this is what I’ve done so far, I’ve put both Regions and Divisions in separate lists and called by looping it inside the <c:foreach> as shown below,

<c:forEach var="DivisionList" items="${RegionSection.DivisionList}" varStatus="vs">
<c:if test="${DivisionList.divisionID== id}" >  
${DivisionList.title}
</c:if>
</c:forEach>

By using the above, I was able to to get and arrange the whole data without the pipe “|”….to append pipe I’ve tried using the “Last” condition, <c:if test="${!vs.last}"> | </c:if> but this only removes the pipe in the last item of the Division list which is not what I intended…..

Is there a workaround for this that could be implemented using Jstl or do I have to use Javascript to get it working? Any help would be greatly appreciated…

Thanks

  • 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-05-28T13:30:03+00:00Added an answer on May 28, 2026 at 1:30 pm

    You should care about the naming of your variables, because the DivisionList attribute is actually a Division, and should be named as a variable, with a lower-case d: division.

    Just use the reverse tactic: prepend a pipe before every division except the first one, and use a flag to know if the first one has already been displayed:

    <c:set var="first" value="true"/>
    <c:forEach var="division" items="${RegionSection.DivisionList}">
        <c:if test="${division.divisionID == id}">
            <c:if test="${!first}"> | </c:if><c:out value="${division.title}"/>
            <c:set var="first" value="false"/>
        </c:if>
    </c:forEach>
    

    Also, Using c:out makes sure that special HTML characters (like <, >) are properly escaped.

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

Sidebar

Related Questions

I have a SQL Server 2000 database that will not display the column list
I am just trying to display a list from an array that I have
I have a database table with a sortOrder column. I display this list to
I have created an array list from a database column and I want to
I have a ASP.NET/VB that had a GridView to display a list of users
I have a crystal report that is connecting to a database. The datatable from
On my index/list view I have a list of records from the database, currently
I want to fetch data from SQLITE database and display it in a LIST.
I have a members name coming from a database. Now I need to display
With the display list in Actionscript 3.0, I'm often inclined to have children add

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.