Search code examples
javajsp-tags

Why is <taglib> giving me a problem in my web.xml?


I have this web.xml

<?xml version="1.0" encoding="UTF-8"?>
  <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
   <display-name>jsp-tags</display-name>
     <taglib>
       <taglib-uri>mytags</taglib-uri>
       <taglib-location>/WEB-INF/mytaglib.tld</taglib-location>
    </taglib>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
   </welcome-file-list> 
</web-app>

The is highlighted and the error the IDE gives is: "Invalid content was found starting with element ...

What more do I need to do?


Solution

  • Use this notation:

    <jsp-config> 
            <taglib> 
                   <taglib-uri>mytags</taglib-uri> 
                   <taglib-location>/WEB-INF/jsp/mytaglib.tld</taglib-location> 
            </taglib> 
    </jsp-config>
    

    But I recommended to read this link. This tutorial will give you idea how to avoid declaring taglibs in web.xml in case of JSP 2.0