Results 1 to 3 of 3
  1. #1
    Robert_85 is offline Member
    Join Date
    Mar 2009
    Rep Power

    Default Loop through Array in JSP

    Hi Guys,

    Please Help, I had the same post before, but no one replied. please:

    I've got a big problem with these JSP/JSPX pages. I'm sure you people can help me.

    Basically I am passing an array of strings from a Java servlet to a JSP page where I am trying to go through the array using 'forEach' loop and for each element, invoke a MYSQL command.

    The array is called "Websites".

    Here is my code:

    <c:forEach var="e" begin="0" step="1" end=${Websites.length}>

    <sql:query var="table">
    select SUM(usability) as number from ${Websites[e]};

    I have two main problems, firstly in the ForEach Tag, "Website.length" is not working, it returns SQL error at run time.
    secondly in the MySql command, "${Website[e]}" is not working too, it returns SQL error at run time as well.

    PLease Please help because I have been spending so much time on this. :(:(:(

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    I think Websites has to be a collection, e.g. ArrayList, not array ?

  3. #3
    flyfisherman is offline Member
    Join Date
    Mar 2010
    Rep Power

Similar Threads

  1. Loop through an Array and invoke SQL command
    By Robert_85 in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-25-2010, 12:14 PM
  2. Finding a the max value of the array using a for loop
    By soccer_kid_6 in forum New To Java
    Replies: 1
    Last Post: 04-11-2010, 11:25 PM
  3. How do I create an array with every cycle of a loop?
    By blackhole8746 in forum New To Java
    Replies: 3
    Last Post: 05-07-2008, 07:49 AM
  4. Replies: 2
    Last Post: 05-05-2008, 01:56 PM
  5. Timing array loop performance
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 08:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts