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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:11:11+00:00 2026-06-01T15:11:11+00:00

I have forwarded an array userName[][] from a servlet to a JSP. I can

  • 0

I have forwarded an array userName[][] from a servlet to a JSP. I can access the array elements like ${userName[2][3]}, but i cant iterate through the array using a variable. e.g. ${userName[i][j]} or ${userName[<%=i>][<%=j>]} dont work.

also, should i declare my index variables as var(JS) as my code also uses JS to plot a graph from the array,or do I need to use JSTL? I’m a complete newbie to JSP

  • 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-01T15:11:12+00:00Added an answer on June 1, 2026 at 3:11 pm

    Here’s how you iterate through an array in JSTL (Note that I pluralized your userName variable, since it’s an array):

    <c:forEach var="userName" items="userNames">
        // do something with the userName
    </c:forEach>
    

    Since you array is an array of arrays, you can nest two iterations:

    <c:forEach var="innerArray" items="userNames">
        <c:forEach var="element" items="innerArray">
             // do something with the element
        </c:forEach>
    </c:forEach>
    

    Note that JavaScript executes at client-side, whereas the JSP is executed at server-side. When JS code executes, it doesn’t have access to your server-side Java array. If you need to access the contents of the Java array at client-side, you should serialize it with JSON, and parse the resulting JSON String in JavaScript.

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

Sidebar

Related Questions

We have a service hosted behind our firewall that receives request forwarded through to
I have an array of arrays, like so: [['1','2'],['a','b'],['x','y']] I need to combine those
I have got an array of objects in ruby and I want to iterate
I have a php array that gets returned from a database, the array contains
I have to implement a kind of an array or sequence or list, which
I'm working on a project where we have an array of atoms which acts
I have a huge binary string, like: 1110 0010 1000 1111 0000 1100 1010
This is probably straight forward enough but for some reason I just can't crack
I have a large array of numerical data that I need to sort, insert,
Lets say that I have an array, foo , in R that has dimensions

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.