I have application and I want to use jstl tag lib
.
I have two jars JSTL.jar
and standard.jar
. I put both in my WEB-INF/lib
You made several mistakes:
web.xml
. This is a myth.web.xml
for Tomcat 7.Remove them all. Remove all <taglib>
from web.xml
. Remove the both JARs from /WEB-INF/lib
. Then follow the following steps:
/WEB-INF/lib
.Fix your web.xml
to be Servlet 3.0 compatible.
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- Config here. No taglibs! -->
</web-app>
Use the documented taglib declaration:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
I have a vague suspicion that you're using Roseindia.net as a Java EE resource. Your invalid approach is also mentioned in there. You should not do that. You should put that site in your Internet blacklist. This site is so full of bad answers and bad practices. Use Oracle's official resources instead, or Stackoverflow.com of course.
You don't need to configure taglibs in web.xml anymore. Plus you're defining different taglib urls (iirc the web.xml ones are correct).
Use the uris from your web.xml in the jsp and remove the web.xml taglib defs.
If you are one of the lucky few that have to support old code and removing taglib
in your web.xml
is not an option. You can enclose it in <jsp-config>
like so:
<jsp-config>
<taglib>
<taglib-uri>/taglibs/custom-taglib</taglib-uri>
<taglib-location>/WEB-INF/custom-taglib.tld</taglib-location>
</taglib>
</jsp-config>