Unknown tag(c:out) or Unknown tag(c:if)
(c:out) and (c:if) tags are JSTL (JavaServer Pages Standard Tag Library)tags used on the JSP's they have many functionalities like iteration,condition, formatting, xml tags , sql tags , internationalisation tags which are common to many JSP pages and there are many such JSTL tags like (c:foreach), (c:set), (c:remove),etc .
JSTL has many other tags like Core tags which starts with c: , Formatting tags which starts with fmt:, SQL tags which starts with sql: , XML tags starting with xml: and JSTL functions starting with fn:
If any of these tags shows Unknown tags when used on the JSP page then we must follow the below given steps
The root cause of this error is if we are trying to use JSTL tags in our application and the web application does not have JSTL libraries support which does not come by default with the J2EE application, So we need to add the JSTL libraries in the application's classpath and also it is needed at the runtime. To make it available need to follow some steps.
Following steps to be followed when the JSTL tags are used in the web application:
1) Download jstl.jar from mvnrepository or java2s site (jstl-1.2 version is the latest one)
To add it in build path from Eclipse, Right click on the project-> Properties-> Java Build Path-> Add external jar or added in the lib folder->Click ok. This will add it to the build path.
(This jar should be in the applications build path for compilation and servers lib folder-classpath for runtime execution)
2) Drop in /WEB-INF/lib folder of your webapp or the application servers lib folder (the /WEB-INF/lib folder is part of the webapp's runtime classpath) or add it in the maven dependency if Maven project is used or gradle file id Gradle project is used.
3)And Need to add taglib declaration at the top of the page as it will make the jstl libraries available to the JSP page.
If tag starting with c: i.e. the core tag e.g. <c:XXX> is Unknown then add
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
The above taglib declaration is for JSTL core tags likewise
if it shows tag starting with fn: i.e. the function tags e.g. <fn:XXX> is Unknown then add
<%@ taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions" %>
If tag starting with x: i.e. the xml tags e.g. <x:XXX> is Unknown then add
<%@ taglib prefix = "x" uri = "http://java.sun.com/jsp/jstl/xml" %>
If tag starting with sql: e.g. <sql:XXX> is Unknown then add
<%@ taglib prefix = "sql" uri = "http://java.sun.com/jsp/jstl/sql" %>
If tag starting with fmt: i.e. the formatting tags e.g.<fmt:XXX> is Unknown then add
<%@ taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt" %>
The purpose of JSTL is to replace the scriplets in the JSP.
And also note JSTL 1.2 requires Servlet 2.4 or upper version. This Servlet version can be verified in the WEB-INF/web.xml file of the web application.
Note: If anyone feels to suggests some updates then please add it to the ccomments section
Comments
Post a Comment