jsptaglib

how to update multiple check box value when retrived from database


using this tag lib

    <%@taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

but getting error

The function contains must be used with a prefix when a default namespace is not specified

i am using this method . to make multiple check boxed checked while fetching from database

   <c:set var="medium" value="<%=rs.getString("medium")%>" />

       English
    <input type="checkbox" name="C1" <c:if test="${fn:medium.contains('English')}">checked</c:if>>
    Kannada
    <input type="checkbox" name="C1"
           <c:if test="${medium.contains('Kannada')}">checked</c:if>>
    Hindi
    <input type="checkbox" name="C1"
           <c:if test="${medium.contains('Hindi')}">checked</c:if>>

Solution

  • Change your code to :

        English
        <input type="checkbox" name="C1" 
               <c:if test="${fn:contains(medium,'English')}">checked</c:if>>
        Kannada
        <input type="checkbox" name="C1"
               <c:if test="${fn:contains(medium,'Kannada')}">checked</c:if>>
        Hindi
        <input type="checkbox" name="C1"
               <c:if test="${fn:contains(medium,'Hindi')}">checked</c:if>>
    

    and include taglibs

    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
    

    http://www.tutorialspoint.com/jsp/jstl_function_contains.htm