How to know if List is empty or not in Struts2?
list, struts2
Solution
You can use Struts2 `<s:if>` and `<s:else>` tags for conditional checking like this:
<s:if test="%{getProductList().isEmpty()}">
Error
</s:if>
<s:else>
<s:iterator value="productList">
<tr style="background-color: #99CCFF">
<td><s:property value="pid"/></td>
<td><s:property value="productname"/></td>
<td><s:property value="producttype"/></td>
<td><s:property value="productprice"/></td>
<td><s:property value="shopname"/></td>
<td><s:property value="productcity"/></td>
<td><s:property alue="ownername"/></td>
</tr>
</s:iterator>
</s:else>
Problem
I have one List. Which is fetch from java class to jsp page. I want to display this List in jsp page but, if List is empty then display one error message otherwise display List's item. ``` <s:iterator value="productList"> <tr style="background-color: #99CCFF"> <td><s:property value="pid"/></td> <td><s:property value="productname"/></td> <td><s:property value="producttype"/></td> <td><s:property value="productprice"/></td> <td><s:property value="shopname"/></td> <td><s:property value="productcity"/></td> <td><s:property alue="ownername"/></td> </tr> </s:iterator> ```