Tuesday, November 5, 2013

how to compare string values using jstl fn

At first~!

in html we need to add Declare using jstl

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

this is really good i think

       
        <jsp:useBean id="extension" class="java.util.HashSet" scope="request">
           <%
         extension.add("ap");extension.add("avi");extension.add("bmp");extension.add("doc");
         extension.add("docx");extension.add("exe");extension.add("gif");extension.add("gul");
               extension.add("htm");extension.add("html");extension.add("hwp");extension.add("jpg");
               extension.add("log");extension.add("mht");extension.add("mp3");extension.add("pdf");
               extension.add("png");extension.add("ppt");extension.add("pptx");extension.add("tif");
               extension.add("tiff");extension.add("txt");extension.add("vcf");extension.add("wav");
               extension.add("xls");extension.add("xlsx");extension.add("xml");extension.add("zip");
           %>
       </jsp:useBean>
       <c:choose>
        <c:when test="${fn:contains(extension, attach.contentType)}">
         <img src="/neo/img/neo/theme/fileIcon/file_${attach.contentType}.gif"/>${attach.name} ${attach.size }bytes</a>
        </c:when>
        <c:otherwise>
         <img src="/neo/img/neo/theme/fileIcon/file_unknown.gif"/>${attach.name} ${attach.size }bytes</a>
        </c:otherwise>
       </c:choose>

No comments:

Post a Comment