Reputation: 405
In my jsp page I am specifying:
<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 it gives me 500 error with
The function contains must be used with a prefix when a default namespace is not specified
I am not able to understand it. What is wrong?
Upvotes: 4
Views: 12253
Reputation: 9290
Check this out: JSTL fn:contains() function
Used to find a String inside another one (I guess this is 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>
Don't forget to include the taglib in your JSP to use it:
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
Upvotes: 6
Reputation: 28015
You can use your static method in EL (which I assume com.community_classification_id.contains
is) but first you have to define custom EL function.
Check 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 prefix like shown in those answers.
Upvotes: 1