title: JSTL Access Integer/Long key in Hash Map
body: <p>I am facing some problem in using EL in JSTL and not able to access Java Hash Map as I would like. I am aware that in EL the key, if Integer gets accessed as Long. I have following hash map definition that I am trying to access in JSTL - </p>
  
  <pre><code>Map&lt;Long, Object&gt; testMap = new HashMap&lt;Long, Object&gt;();
  </code></pre>
  
  <p>In JSP page, I need to check if the map contains a specific key or not. I attempt to do that by checking if not empty as following -</p>
  
  <pre><code>&lt;c:if test='${ ! empty testMap[currObj.currVal]}'&gt;
  </code></pre>
  
  <p>I also access the map's value for a key somewhere in the code like below -</p>
  
  <pre><code>&lt;c:if test='${ testMapMap[5].data == 'something'}'&gt;
  </code></pre>
  
  <p>Now the problem -</p>
  
  <p>If i define my map above as <code>&lt;Integer, Object&gt;</code> then the first c:if works but second fails (as the second tries to access it as Long). However, if I define my map above as <code>&lt;Long, Object&gt;</code> the first if check always fails as it always recognizes it as empty but the second if statement where I check for the value works.</p>
  
  <p>Is there any good way to make sure I access HashMap for both the if statements correctly? I will appreciate opinions.</p>