JSP EL usage error: "This function should be used with a prefix if no default namespace is specified"
On my jsp page I point out:
<c:choose> line 1: <c:when test="${com.community_classification_id.contains('1')}"> <input type="checkbox" id="by_invitation1" name="invitaion" value="1" checked="true">By Invitation<span style="padding-left:28px"></span> </c:when> <c:otherwise> <input type="checkbox" id="by_invitation1" name="invitaion" value="1">By Invitation<span style="padding-left:28px"></span> </c:otherwise> </c:choose> but @line no. 1 he gives me a 500 error with
The function contains must be used with a prefix when a default namespace is not specified I canβt figure it out. What's wrong?
Check this out: JSTL fn: contains () function
Used to find a string inside another (I think this is what you are trying to achieve)
In your code:
<c:choose> <c:when test="${fn:contains(com.community_classification_id, '1')}"> <input type="checkbox" id="by_invitation1" name="invitaion" value="1" checked="true">By Invitation<span style="padding-left:28px"></span> </c:when> <c:otherwise> <input type="checkbox" id="by_invitation1" name="invitaion" value="1">By Invitation<span style="padding-left:28px"></span> </c:otherwise> </c:choose> Remember to include taglib in your JSP to use it:
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> You can use your static method in EL (which I assume com.community_classification_id.contains is), but you must first define a custom EL function.
Mark this answer and this answer , which shows how to create and use EL functions in JSP. Then just remember to import your taglib and use your static method with a prefix, as shown in these answers.