Here is demonstration code.
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<c:set var="questionList" value='${["What color is the sky?","Who invented the telephone?","Which country has the biggest population?"]}'/>
<c:set var="queChoicesMap" value='${{1:["green","brown","blue"],2:["Smith","Bell","Jones"],3:["China","India","USA"]}}'/>
<html>
<body>
<c:forEach items="${questionList}" var="question" varStatus="status">
${question}
<c:forEach items="${queChoicesMap[(status.count).longValue()]}" var="choice" varStatus="choiceStatus">
<br/> ${choiceStatus.count})${choice}
</c:forEach> <br/>
</c:forEach>
</body>
</html>
If some of the syntax looks strange to you, then look at
http://docs.oracle.com/javaee/7/tutorial/jsf-el004.htm
If you are wondering why the longValue method is there, then look at
EL access a map value by Integer key
Edit:
If you read
https://stackoverflow.com/tags/el/info
then you will see that the code above here needs EL version 2.2
To find out which version you are using, read BalusC answer at
How can I check what version of EL is server using
or run the following JSP code.
Server Version:
${pageContext.servletContext.serverInfo}
Servlet Version:
${pageContext.servletContext.majorVersion}.${pageContext.servletContext.minorVersion}
If you using an older version, then you could use one of the following codes.
But, they have an ugly scriptlet in them. The code in those scriptlets should be moved off into a "tag file" or a "custom EL function".
<%@page import="java.util.*" %>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%
ArrayList<String> questionList = new ArrayList<String>();
questionList.add("What color is the sky?");
questionList.add("Who invented the telephone?");
questionList.add("Which country has the biggest population?");
pageContext.setAttribute("questionList", questionList);
ArrayList<String> listOne = new ArrayList<String>();
listOne.add("green");
listOne.add("brown");
listOne.add("blue");
ArrayList<String> listTwo = new ArrayList<String>();
listTwo.add("Smith");
listTwo.add("Bell");
listTwo.add("Jones");
ArrayList<String> listThree = new ArrayList<String>();
listThree.add("China");
listThree.add("India");
listThree.add("U.S.A.");
HashMap<Integer,List<String>> choicesMap = new HashMap<Integer,List<String>>();
choicesMap.put(1, listOne);
choicesMap.put(2, listTwo);
choicesMap.put(3, listThree);
pageContext.setAttribute("choicesMap", choicesMap);
%>
<html>
<body>
<c:forEach items="${questionList}" var="question" varStatus="status">
${question}
<c:forEach items="${choicesMap[status.count]}" var="choice" varStatus="choiceStatus">
<br/> ${choiceStatus.count})${choice}
</c:forEach> <br/>
</c:forEach>
</body>
</html>
and
<%@page import="javax.servlet.jsp.jstl.core.LoopTagStatus" %>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<c:set var="questionList" value='${["What color is the sky?","Who invented the telephone?","Which country has the biggest population?"]}'/>
<c:set var="choicesMap" value='${{1:["green","brown","blue"],2:["Smith","Bell","Jones"],3:["China","India","U.S.A."]}}'/>
<html>
<body>
<c:forEach items="${questionList}" var="question" varStatus="status">
${question}
<%
LoopTagStatus status = (LoopTagStatus)pageContext.getAttribute("status");
long count = new Integer(status.getCount()).longValue();
pageContext.setAttribute("count", count);
%>
<c:forEach items="${choicesMap[count]}" var="choice" varStatus="choiceStatus">
<br/> ${choiceStatus.count})${choice}
</c:forEach> <br/>
</c:forEach>
</body>
</html>