How would I make the following code work?
<c:if test="${null != searchResults}" >
<c:forEach items="${searchResults}" var="result" varStatus="status">
I've tried many different variations of this, such as:
<c:if test="${searchWasPerformed}" >
or
<c:if test="<%=request.getAttribute("searchWasPerformed") %>" >
and even
<% boolean b = null != request.getAttribute("searchResults"); %>
<c:if test="${b}" >
Which looks REALLY ugly :/ But I keep on getting the
org.apache.jasper.JasperException: /WEB-INF/jsp/admin/admin-index.jsp(29,2) PWC6236: According to TLD or attribute directive in tag file, attribute test does not accept any expressions
How would I go around this?
The < c:if > tag is used for testing the condition and it display the body content, if the expression evaluated is true. It is a simple conditional tag which is used for evaluating the body content, if the supplied condition is true.
All you need to do is: Download the zip, extract it, open its /lib folder and copy jstl. jar and standard. jar files in /WEB-INF/lib folder (thus, not /lib ) of your webapp.
The first way is to use the JSTL tag and empty operator to check if an ArrayList is empty and the second way is to use the JSTL function, fn: length() instead of the empty operator as shown in our example.
The <c:out> tag is similar to JSP expression tag, but it can only be used with expression. It will display the result of an expression, similar to the way < %=... % > work.
Check version of JSTL taglib you use. It should be 1.1, so you should have (note the URI):
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With