title: How to show one Item at a time from Java ArrayList
body: <p>I wonder if anyone can help, I'd like to Iterate over ArrayList but One item at a time with help of some button so when I press that button it would show me the next item in the list and so forth. Or if there's another way I'd be happy to take any advice. I'm trying to design a test so a student would get one question at a time he/she would submit the answer and it would move to the next question. This is what I have as showing full list on JSP.
  My Servlet</p>
  
  <pre><code>        String vassId = request.getParameter("vassId");
          List&lt;Assessment&gt; qList = new ArrayList&lt;Assessment&gt;();
          Assessment qObj = null;
          DbConnection dbConn = null;
          Connection conn = null;
          CallableStatement proc = null;
          response.setContentType("text/html");
          ResultSet rs = null;
  
          try {
              dbConn = new DbConnection();
              conn = DbConnection.connection();
  
              String dbCall = "{ ? = call pa_customer_admin.fn_list_question(?) }";
              proc = DbConnection.connection().prepareCall(dbCall);
              proc.registerOutParameter(1, OracleTypes.CURSOR);
              proc.setInt(2, Integer.parseInt(vassId));
              proc.execute();
              rs = (ResultSet) proc.getObject(1);
              while (rs.next()) {
                  qObj = new Assessment();
                  qObj.setVassId(Integer.parseInt(rs.getString(1)));
                  qObj.setDescr(rs.getString(2));
                  qObj.setQuesStatus(rs.getString(3));
                  qObj.setQuesTypeCode(rs.getString(4));
                  qObj.setCreatedDate(rs.getString(6));
                  qObj.setQuestion(rs.getString(7));
                  qObj.setMark(rs.getString(8));
                  qObj.setTimeLimit(rs.getInt(9));
                  qList.add(qObj);
              }
              request.setAttribute("qObj", qObj);
              request.setAttribute("qList", qList);
              proc.close();
  </code></pre>
  
  <p>JSP</p>
  
  <pre><code>                   &lt;form action="AnswerSaveProcess" method="POST" &gt;
                      &lt;c:if test="${empty qList}"&gt;
                          Empty list
                      &lt;/c:if&gt; 
                      &lt;c:if test="${! empty qList}"&gt;
                          &lt;c:forEach items="${qList}" var="q"&gt;
                              &lt;label&gt;Question&lt;/label&gt;
                              &lt;input type="hidden" value="&lt;%= vassId%&gt;"&gt;
                              &lt;textArea readonly="readonly"&gt;${q.question}&lt;/textarea&gt;
                              &lt;input type="text" value="${q.mark}" readonly="readonly"&gt;                              
                              &lt;input type="hidden" id="userTime" value="${q.timeLimit}" /&gt;
  
                              &lt;label&gt;Answer 1&lt;/label&gt;
                              &lt;input type="text"  &gt;&lt;input name="ansStatusCode" type="radio"&gt;&lt;br/&gt;
                              &lt;label&gt;Answer 2&lt;/label&gt;
                              &lt;input type="text" &gt;&lt;input name="ansStatusCode" type="radio"&gt;&lt;br/&gt;
                              &lt;input type="submit" name="submit" value="Save Answer"&gt;
                          &lt;/c:forEach&gt;
                      &lt;/c:if&gt;
                  &lt;/form&gt;
  </code></pre>