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

The Archive Base Latest Questions

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

I having a doubt regarding accessing an array of arraylist in jsp using iterator

  • 0

I having a doubt regarding accessing an array of arraylist in jsp using iterator tag.

In my action class i used the following codes..,

ArrayList[] arr= new ArrayList[10]; 

for(int i = 0; i < 10; i++) { 
    arr[i] = new ArrayList<bean>();
} 

while (some conditions) { 
    arr[i].add(new bean(some values)); 
    i++; 
}

My question is.. how can i access the arr[0],arr[1]…arr[n] arraylists in iterator..?

The following code is working perfectly.., but please improve it to achieve my result..!

<s:iterator value="display.arr[0]">
  ...
</s:iterator>

Helps will be appreciated..!

  • 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-30T05:51:04+00:00Added an answer on May 30, 2026 at 5:51 am

    I’m wondering if you looked at the iterator tag documention much; there are at least 3-4 ways to go about doing this, including using an immediate list of indexes, using the "begin"/"end" attributes, using "var" to hold the outer item (not strictly necessary, but IMO it’s more communicative), etc.

    Assume a property named "s" in the bean class, which I call SomeBean:

    <s:iterator value="displays" var="display">
      <s:iterator value="#display">
        ${s}<br/>
      </s:iterator>
    </s:iterator>
    

    Using the Java code at the bottom, this produces the following output:

    Outer: 0, Inner: 0
    Outer: 0, Inner: 1
    Outer: 0, Inner: 2
    Outer: 1, Inner: 0
    Outer: 1, Inner: 1
    Outer: 1, Inner: 2
    Outer: 2, Inner: 0
    Outer: 2, Inner: 1
    Outer: 2, Inner: 2
    

    The complete action driving this code; I just return a new list every time as an example:

    public class NestedListsAction extends ActionSupport {
    
        public List<List<SomeBean>> getDisplays() {
            List<List<SomeBean>> displays = new ArrayList<List<SomeBean>>();
    
            for (int i = 0; i < 3; i++) {
                List<SomeBean> innerList = new ArrayList<SomeBean>();
                for (int j = 0; j < 3; j++) {
                    innerList.add(new SomeBean(String.format("Outer: %d, Inner: %d", i, j)));
                }
                displays.add(innerList);
            }
    
            return displays;
        }
    
        private class SomeBean {
            private String s;
    
            public SomeBean(String s) {
                this.s = s;
            }
    
            public String getS() {
                return s;
            }
        }
    
    }
    

    Note the SO policy on accepting answers. Normally I wouldn’t bring it up to a new user, but IMO I expended more effort answering this question than you did researching it, which makes me depressed.

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

Sidebar

Related Questions

I am having following doubt regarding int flavors (unsigned int, long int, long long
I build a parsing algorithm using NSXMLParser. Im having doubt as to what is
I am having a doubt regarding a project structure. I am having a project
i m having a doubt regarding which one is better option to use ?
I am using JQuery for my application. Having a doubt on how to add
I'm having some problems with the following code: private class ClientPluginLoader : MarshalByRefObject {
I'm having the following doubt about contexts in entity framework: Suppose that there are
I am having one doubt regarding the use of static variable in Asp.net pages.
I'm having a doubt regarding the memmory allocation for anonymous type variable. if i
I have some doubts regarding the following controller action (in ASP.NET MVC, but it's

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.