I am very new to JSTL.
Now I have created an HashMap and rendered it in the jsp page .
This is how I Have crated the HashMap
In Application Level :
public HashMap<String, String> uploadSmelter(){
HashMap<String, String> progress = new HashMap<String, String>();
try {
CompanyEntity instanceNew = (CompanyEntity) sessionFactory.getCurrentSession()
.createCriteria(CompanyEntity.class)
.add(Restrictions.eq("name", smObj.getName()))
.add(Restrictions.eq("metal", MetalEnum.valueOf(metal))).uniqueResult();
if (instanceNew != null){
//logger.info();
progress.put("error", Integer.toString(1));
progress.put("errorMsg", "Company : " +smObj.getName() + " for Metal: " + metal + " exists." );
}
}
return progress
}
In Controller Level :
HashMap<String, String> result = new HashMap<String, String>();
result.put("error", "0");
result.put("update", "0");
result.put("create", "0");
HashMap<String, String> progress = new HashMap<String, String>();
int number = 0;
while (rowIterator.hasNext())
{
progress= companyFacade.uploadSmelter(); // implemented in application level uploadSmelter method
if(progress.get("errorMsg")!=null){
result.put(Integer.toString(number),progress.get("errorMsg"));
}
number=number+1 ;
}
Now finally if I print it in the jsp page , i am getting
{3=Company: ABC COMPANY for Metal: A Exists, update=0, 2=Company: ABC COMPANY TIN for Metal TIN Exists, 1=Company: ABC COMPANY G for Metal METAL_TANTALUM Exists, 0=Company: ABC COMPANY L for Metal METAL_TANTALUM Exists, error=4, fileName=data.1407219942830.xls, number=4, create=0}
Now I want to run a foreach loop in jsp page that should print filtered value from the Hashmap.
So I have added those condition in JSTL if statement . But seems to be it is not supporting the condition statement and I am not getting any output .
<c:forEach items="${result}" var="item">
<c:if test="${item.key} !='update' && ${item.key} !='error' && ${item.key} !='create' && ${item.key} !='number' && ${item.key} !='fileName'}" >
<div class="attributeField">Line Number <c:out value="${item.key}" /> <spring:message message="${item.value}"/></div>
</c:if>
</c:forEach>
So what the mistake I am doing ? Thanks for help in Advance.