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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:49:18+00:00 2026-06-01T01:49:18+00:00

I have 4 arraylist in jsp and I want to get elements of lists

  • 0

I have 4 arraylist in jsp and I want to get elements of lists from javascript function.

it looks like there is no problem getting one element from jsp arraylist.

But I don’t know how to move multiple or all elements from jsp arraylist to javascript code.

below is my code

<script>
    function makeTable(){
    for(c=0;c<row_num;c++){
        row[c]=document.createElement('tr'); 
        for(k=0;k<cell_num;k++) {
            cell[k]=document.createElement('td');
            cont = document.createElement('a');
            cont.href="./bbs_view.jsp?count=" + c;
            cont.innerHTML ="<%=title.get(0)%>";
            cell[k].appendChild(cont);
            row[c].appendChild(cell[0]);
        }
    }
}
</script>

as you can see, above function can get only one element from jsp arraylist.
is there any way to replace <%=title.get(0)%> to
something like <%=title.get( javascript var c)%>?

  • 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-01T01:49:19+00:00Added an answer on June 1, 2026 at 1:49 am

    Emit a javascript array within your scriplet (assumin titles is a java collection of Strings) and use the js counterpart of your array.

    <script>
    
    var jsArray = [];
    
    <% int i = 0; foreach (String iterat : titles) { %>
    
    jsArray[<%= i %>] = '<%= iterat %>';
    
    <% i++; } %>
    </script>
    

    Is roughly unelegant (better have this in a custom tag, but should work).

    BEWARE: typed on the fly, can have syntax typos in ^^

    BigMike

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

Sidebar

Related Questions

I have a ArrayList made up of different elements imported from a db, made
I have an ArrayList<String> , and I want to remove repeated strings from it.
I have a JSP that takes an Arraylist from the session object and removes
I want to implement custom JSP list tag, but have problem with accessing properties
I have arraylist myorderdata . I want to retrieve this arraylist to one String
I have an ArrayList<String> that I'd like to return a copy of. ArrayList has
i get a list from my java code and I would like to create
I have an ArrayList which contains cutomer name details. In my JSP I am
In my code, I have used ArrayList which stores the number format like '$0.00
Hello i have a JSP page that contain a form, i want to validate

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.