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

  • Home
  • SEARCH
  • 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 7578891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:32:22+00:00 2026-05-30T17:32:22+00:00

HelloTag.Java public class HelloTag extends SimpleTagSupport { @Override public void doTag() throws JspException, IOException

  • 0

HelloTag.Java

public class HelloTag extends SimpleTagSupport {

@Override
public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();

    ArrayList outerList = new ArrayList();
    ArrayList innerList = null;
    for (int i = 0; i < 5; i++) {
        innerList = new ArrayList();
        innerList.add("1");
        innerList.add("Name");
        outerList.add(innerList);
    }
    for (int i = 0; i < outerList.size(); i++) {
        for (int j = 0; j < innerList.size(); j++) {
            out.println(innerList.get(j));
        }
    }
}
}

In JSP File,
There is following code snippet:

 <body>
    <ct:Hello></ct:Hello>
</body>

When I run the JSP file, this file showing the accurate result; but

I want to take the decision of every value that come from custom tag class

such as

 <c:set var="name" scope="" value=""/>
 <c:choose>
 <c:when test="${name == 1}">
  This is Your ID:-
 </c:when>
 <c:otherwise>
    This is Your Name
 </c:otherwise>
 </c:choose>

The above code is the just for sake of example. please update me how take decision on each value that comes form custom tag class.

Other way to explain my problem is that, I want to store every value in a variable , and then take a decision about that value just using JSTL without Scriplet Tags focusing on the above scenario (HelloTag.Java )

  • 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-30T17:32:23+00:00Added an answer on May 30, 2026 at 5:32 pm

    It’s really not clear what you’re asking. But your tag, as it is, just loops through each inner list of an outer list (well, in fact, I guess it should do that, but it has a bug, so it doesn’t).

    You don’t need a custom tag to do that, since the JSTL <c:forEach> tag does that already. Suppose you have an outerList stored in a request (or page, or session, or application) attribute:

    <%-- iterate through the outer list --%>
    <c:forEach var="innerList" items="${outerList}">
        <%-- iterate through the innerList --%>
        <c:forEach var="element" items="${innerList}">
            <%-- do what you want with the element --%>
        </c:forEach>
    </c:forEach>
    

    From your question, it seems to me that you shouldn’t have an inner list, though. Rather, the outer list should contains objects (instances of a Person class, for example) which have a getId() and and a getName() methods. The loop would thus be:

    <%-- iterate through the outer list --%>
    <c:forEach var="person" items="${personList}">
        ID : ${person.id}<br/>
        Name : <c:out value="${person.name}"/>
    </c:forEach>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the following class in a JSP-based custom tag: public class
I've created a custom component that display some data to the page according to
I have downloaded the latest version of tomcat 7 i.e 7.0.23 as of 1/16/2011.
I wanna create Contextual Tab using Webpart In Sandbox Solution..that time I am getting
I'm having quite a hard time deciding on the best way to delete my

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.