I am loading a map of values into ServletContext during start of the application/server
HashMap<String, List<String>> cfsUfsMap = new HashMap<String, List<String>>();
//some operations
application.setAttribute("UDM_UFS_CFS_MAP", cfsUfsMap); //application = ServletContext
I need to use this map directly in JSP page, for which I have done this
<s:set name="udm_cfs_ufs_map" value="#application.UDM_UFS_CFS_MAP" />
<table class="first" width="100%" border="0" cellpadding="0" id="sups_assignedservices_info_table">
<tr>
<th width="30%">Assigned service name </th>
<th width="15%">CFS Code </th>
<th width="15%">Status </th>
<th width="20%">Date </th>
<th width="20%">UDM </th>
</tr>
<s:iterator value="#sups_services.services">
<s:set name="ufs_list" value="#udm_cfs_ufs_map.['top.code']" />
<tr>
<td class="light"><s:property value="top.name"/> </td>
<td class="light"><s:property value="top.code"/> </td>
<td class="light"><s:property value="top.status"/> </td>
<td class="light"><s:property value="top.date"/> </td>
<td class="light"><s:property value="#udm_cfs_ufs_map.size()" /> - <s:property value="#ufs_list.size()" /></td>
</tr>
</s:iterator>
As you see, I am trying to get the values (List) from map using key which’s top.code
However I am getting original map size but not the list size based on key.
Any idea what’s missing/going wrong
Done.
I solved it myself. I am posting my mistakes and the correct solution. SO down the line it might be useful to someone
to access servletContext attributes
for fetching the content from the map based on key