0

I am new to jsp and using jstl library. I have a HashMap and a List of Keys to print corresponding in an ordered fashion.

I am doing:

<%
    request.setAttribute("obj", javaObject);  //javaObject contains a map and list
%>

<c:forEach var="x" items="${obj.listElem}">
   ${obj.map[$x]}     //does not print map content for a Key
</c:forEach>

Am I missing something here?

SIGSTP
  • 1,125
  • 2
  • 9
  • 21
  • 4
    Just get rid of the `$` in `$x`. By the way, this is not specifically JSTL, but more EL. It seems that you're new to EL as well. It's time to read http://stackoverflow.com/tags/el/info (and also http://stackoverflow.com/tags/jstl/info in order to learn what "JSTL" really is) – BalusC Aug 21 '13 at 19:36
  • but I am using only jstl/core taglib. Will EL work in that case or I need to include EL taglib – SIGSTP Aug 21 '13 at 19:43
  • Huh? It look like you didn't understood me at all. Again, just remove the `$` from `$x` in your code and it'll work. This is so extremely trivial that I can't be bothered to post it as an answer. Maybe someone else in short of reputation will do. – BalusC Aug 21 '13 at 19:47
  • sorry dude. I am dont know anything JSP. sorry for asking a stupid question. – SIGSTP Aug 21 '13 at 20:14
  • If you try, you can find so many posts which can help you. As per BalusC please go and read the articles. Also, I would suggest to first search your problem. Someone might already asked the same problem. Here are the posts you can see - http://stackoverflow.com/questions/924451/el-access-a-map-value-by-integer-key, http://stackoverflow.com/questions/6164560/how-to-use-jstl-foreach-directly-over-the-values-of-a-map – Saurabh Aug 22 '13 at 08:12
  • I tried to search first. I couldn't, may be bacause the post you referred does not contain the keyword JSP. – SIGSTP Aug 22 '13 at 09:05

0 Answers0