I want to create custom tag, but i get "XML parsing error" on JSPVersion line. I check my JSP version, is exactly 2.1. I think error in links.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
<tlib-version>1.0</tlib-version>
<jsp-version>2.1</jsp-version>
Can anyone help me? Thanks
UPD/ ERROR MESSAGE: org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/tlds/tag.tld: (line 11, col 2)
A tag library descriptor is an XML document that contains information about a library as a whole and about each tag contained in the library. TLDs are used by a web container to validate the tags and by JSP page development tools. Tag library descriptor file names must have the extension .
The TLD file: The tag library descriptor (TLD) file is an XML file that contains meta-information about the tags within a library. Information such as the tag name, the attributes that are required, and the tag handler class name are all contained in this file and read in by the JSP container.
Just go for New->XML file and name the file as yourname. tld thats all !
You're using a old JSP 1.2 tag library declaration in flavor of a DTD. You need to remove it (and also the <jsp-version>
) and use the new JSP 2.1 XSD declaration:
<?xml version="1.0" encoding="UTF-8" ?>
<taglib
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/web-jsptaglibrary_2_1.xsd"
version="2.1">
<!-- Taglib config here -->
</taglib>
Ensure that you're reading the proper books/tutorials for JSP 2.1, not JSP 1.2.
Is your DOCTYPE
incorrect? Try the following:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
N.B. I would recommend the advice to update your definition to the Java EE 5 version if, indeed, you do want to use v2.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With