title: Is it possible to control loop(forEach) on click of button on JSP page?
body: <p>I'm trying to create a question/answer quiz where there are multiple choice answers(in radio buttons) per question.
  I want to display One question and it's relevant set of answers at a time. How do I iterate over the list with control so on click it would display the next question and answers?</p>
  <pre><code>    &lt;form action=&quot;/addStuResponse&quot; method=&quot;post&quot;&gt;       
          
          &lt;c:forEach items=&quot;${qlist}&quot; var=&quot;question&quot;  varStatus=&quot;loopCounter&quot;&gt;    
          
              &lt;input type=&quot;hidden&quot; name=&quot;quesSet&quot; value=&quot;${question.quesId}&quot;&gt;     
              &lt;textarea rows=&quot;3&quot; cols=&quot;5&quot; readonly=&quot;readonly&quot;&gt;${question.quesText}&lt;/textarea&gt;
              
              &lt;c:forEach items=&quot;${anslist}&quot; var=&quot;answer&quot;&gt;
                  &lt;c:if test=&quot;${answer.questions.quesId == question.quesId}&quot;&gt;
                      
                      &lt;input type=&quot;radio&quot; name=&quot;response&quot; value=&quot;${answer.answer}&quot;&gt;                           
                  
                  &lt;/c:if&gt;
              &lt;/c:forEach&gt;
          &lt;/c:forEach&gt;
          
              &lt;button type=&quot;submit&quot; &gt;Next&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>