The correct .tld file header

I want to create a custom tag, but I get a "XML parsing error" in the JSPVersion line. I check the JSP version, exactly 2.1. I think the error is in the 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: cannot initialize TldLocationsCache: org.apache.jasper.JasperException: XML parsing error in file / WEB -INF / tlds / tag.tld: (line 11, col 2)

+6
source share
2 answers

You are using the old JSP 1.2 tag library declaration in the spirit of DTD. You need to remove it (as well as <jsp-version> ) and use the new JSD 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> 

Make sure you read the correct books / tutorials for JSP 2.1, not JSP 1.2.

See also:

+13
source

Is your DOCTYPE wrong? 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"> 

NB I would recommend advice on upgrading your definition to Java EE 5 if you really want to use v2.1.

+2
source

Source: https://habr.com/ru/post/902316/


All Articles