title: java, JSTL and getting values by key
body: <p>I would like to know why I am not able to get values from an outer hashtable using the keys in jstl, the keys are integer values, the values are inner hashtables and I am working on some legacy code hence the reason for the Hashtables, which are returned from a stored procedure call in this form. </p>
  
  <p>Oddly in the inner hashtable as I process it in my forEach loop I am able to get those values out... <code>${data['NAME']}</code> actually does work.</p>
  
  <p>I am able to loop over the entire outer hashtable using JSTL forEach loop and its ok but if I try to get a value like <code>${missing_ciphers[1]}</code> or even <code>${missing_ciphers['1']}</code> then nothing is returned.</p>
  
  <p>The hashtable when printed looks like this:</p>
  
  <pre><code>{4={SOURCE=D, NAME=D}, 3={SOURCE=C, NAME=C}, 2={SOURCE=B, NAME=B},   1={SOURCE=A, NAME=A}}
  </code></pre>
  
  <p>I am able to loop over it ok using the following code but the list is not in the order I want it to be in so I wanted to use the loop counter to get objects out by their key but this doesnt seem to return anything (the inline styles will be moved into a css file once I have this working as I want...):</p>
  
  <pre><code>&lt;c:forEach items="${missing_ciphers}" var="ciphers" varStatus="cipher_loop"&gt;
  
                          &lt;c:set var="data" value="${ciphers.value}"&gt;
                          &lt;/c:set&gt;
  
                          &lt;tr style="border-left: none; border-right: none;" class="${cipher_loop.index % 2 == 0 ? 'even' : 'odd'}"&gt;
                              &lt;td&gt;&lt;span style="font-weight: bold;"&gt;${data['SOURCE']}&lt;/span&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;span style="font-weight: bold;"&gt;${data['NAME']}&lt;/span&gt;&lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/c:forEach&gt; 
  </code></pre>
  
  <p>Can anyone help me understand what is happening here and why I am not able to get a value out using the <code>${missing_ciphers[1]}</code> type syntax?</p>
  
  <p>I should add that the following code does print the inner hashtable into the tomcat console: </p>
  
  <p><code>&lt;% System.out.println("val: " + ((Hashtable)request.getAttribute("missing_ciphers")).get(1)); %&gt;</code> </p>
  
  <p>I have even tried the following just to see if it was down to the type of the key this still doesnt get from the outer hashtable:</p>
  
  <pre><code>&lt;c:forEach items="${missing_ciphers}" var="ciphers" varStatus="cipher_loop"&gt;
                          &lt;c:set var="counter" value="${cipher_loop.index + 1}" /&gt;
                          &lt;fmt:parseNumber var="fmt_counter" integerOnly="true" type="number" value="${counter}" /&gt;
                          &lt;c:out value="${fmt_counter}" /&gt;
  
                          &lt;c:set var="data" value="${missing_ciphers[fmt_counter]}"&gt;&lt;/c:set&gt;
  
                          &lt;tr style="border-left: none; border-right: none;" class="${cipher_loop.index % 2 == 0 ? 'even' : 'odd'}"&gt;
                              &lt;td&gt;&lt;span style="font-weight: bold;"&gt;${data['SOURCE']}&lt;/span&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;span style="font-weight: bold;"&gt;${data['NAME']}&lt;/span&gt;&lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/c:forEach&gt;
  </code></pre>
  
  <p>Thanks</p>