title: Access TreeMap entries by string key in JSTL
body: <p>This is pretty similar to some other questions, but nobody else is working with string keys. So here we go.</p>
  
  <p>I've got a TreeMap with a set of category names, keyed by category ID. The ID is a number (as a String).</p>
  
  <p>I build up the TreeMap with values, then expose it to the page, like so:</p>
  
  <pre><code>&lt;%
  Map categories = new TreeMap();
  ...
  String categoryId = ...;
  String categoryName = ...;
  categories.put(categoryId, categoryName);
  ...
  pageContext.setAttribute("categories", categories);
  %&gt;
  </code></pre>
  
  <p>Later, I iterate through a series of items which have been assigned to categories. Each item has a .categories collection which contains the IDs of the categories to which it has been assigned. I want to display the names, so I do something like this:</p>
  
  <pre><code>&lt;c:forEach items="${item.categories}" var="catId"&gt;
      ${categories[“${catId}”}
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>Unfortunately, this doesn't emit anything. Nor does <code>${categories["${catId}"].value}.</code></p>
  
  <p>However, this does:</p>
  
  <pre><code>${categories["2"]}
  </code></pre>
  
  <p>Of course, that line isn't actually driven by item data.</p>
  
  <p>I've checked, and the IDs attached to each item do in fact correspond to category IDs; this isn't a data mismatch problem.</p>
  
  <p>So, how do I get my hands on category names when the data attached to items has only IDs?</p>
  
  <p>P.S. I should mention that I'm not a Java programmer -- at all. LAMP is more my style. So modifying classes isn't really an option.</p>