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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:08:36+00:00 2026-06-13T02:08:36+00:00

I have a problem here in JSTL, I have an array object coming from

  • 0

I have a problem here in JSTL, I have an array object coming from a request attribute that was set in a servlet. All I want to do is to print the indexes of the array. Any help please? Here’s the code:

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="/WEB-INF/tlds/Functions" prefix="func"%>
<table>
    <tr>
        <td>
            <b>k</b> = 
        </td>
        <td>
            <table border="1">
                <c:forEach var="i" begin="0" end="${responseVector.length}">
                <tr>
                    <td>k<sub>${i}</sub></td><!-- I wish to print the indexes here -->
                </tr>
                </c:forEach>
            </table>
        </td>
        <td>
            <table border="1">
                <c:forEach var="i" items="${responseVector}">
                <tr>
                    <td>${func:roundOff(i, 4)}</td>
                </tr>
                </c:forEach>
            </table>
        </td>
    </tr>
</table>
<br/>

In the code above, responseVector is a double array object, but I want the variable i in the first loop to print the indexes of the array object each time the loop iterates. My expected output is: k0, k1, k2, … but am having an exception instead.

  • 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-13T02:08:37+00:00Added an answer on June 13, 2026 at 2:08 am

    Try this: (Use varStatus attribute)

    <c:forEach items="${responseVector}" var="r" varStatus="status">
      <c:out value="${status.index}"/>
    </c:forEach>
    

    ${status.index} will give you:

    Retrieves the index of the current round of the iteration. If
    iteration is being performed over a subset of an underlying array,
    java.lang.Collection, or other type, the index returned is absolute
    with respect to the underlying collection. Indices are 0-based.

    More info here.

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

Sidebar

Related Questions

Here's my problem. I need to set up a process, preferably with jstl/jsp, that
I have a problem here that requires to design a data structure that takes
I have a problem here. DB: oracle 9i I want to save data changes
I have a problem here with cakePHP. I have 4 .ctp view pages that
I have a problem here... After a button is pressed I want a loop
I have a problem here that still cannot solve, the thing is I have
I have problem here, I need all the stuffs inside this $_SESSION['cart'] thing and
Here's my problem: I want to organize my resource bundle files so that I
I have a problem here, I have a String that contains a value of
So I have this problem here: If we list all the natural numbers below

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.