I have a jsp page , In this page I get a hash map from request attribute and I want to extract value for a specific key . The key is availble on jsp . how can I extarct value from map using this key?
I solved this problem by converting java map to java script associative array and then I could fetch value from that array. I would like to share the code :
<%
Map<String,String> currencyCodeMap = (Map<String,String>)application.getAttribute("currPrecisionCodeMap");
%>
<script language="javascript">
var map = new Array();
<%
for (Map.Entry<String, String> entry : currencyCodeMap.entrySet()) {%>
map['<%=entry.getKey()%>'] = '<%=entry.getValue()%>';
<%}
%>
var currencyCode = document.AccForm.currencyname.options[document.AccForm.currencyname.selectedIndex].text;
alert(map[currencyCode ]);// gives value
</script>
above code is working fine but Can Someone provide better solution??