This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Element type "tlibversion" must be declared  RSS feed

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all im trying to make simple taglib but when i try to run it im geting error
my taglib.tld look like :


<?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">
<taglib>
<tlibversion>1.0</tlibversion>
<shortname></shortname>
<tag>
<name>myTag</name>
<tagclass>com.brainysoftware.MyCustomTag</tagclass>
</tag>
</taglib>

and my web.xml looks like this :
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>template</display-name>
<taglib>
<taglib-uri>/myTLD</taglib-uri>
<taglib-location>/WEB-INF/taglib.tld</taglib-location>
</taglib>
</web-app>

and my java file looks like this :
package com.brainysoftware;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class MyCustomTag extends TagSupport {

public int doEndTag() throws JspException {
JspWriter out = pageContext.getOut();
try {
out.println("Hello from the custom tag.");
}
catch (Exception e) {
}
return super.doEndTag();
}
}


simple i know ..
but still im geting the error :
org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/taglib.tld: (line 6, col 16): Element type "tlibversion" must be declared.

when i try to brows to the jsp file that looks like this :

<%@ taglib uri="/myTLD" prefix="easy"%>
<easy:myTag/>

what im doing wrong here?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you look at the DTD for the tld file?
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Making it more obvious, compare the two dtd files:

http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd
http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd

Between 1.1 and 1.2, they changed the syntax of taglibraries.
<tlibversion> became <tlib-version>
<tagclass> became <tag-class>
...

I don't know why, and I think its not very nice of them to do something like that, but its never a perfect world.

Potential Solutions
- upgrade your syntax to the 1.2 dtd
- use the 1.1 dtd instead of the 1.2 dtd in your DOCTYPE declaration.

<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi tnx for the fast reply i did stay with dtd 1.2
but now i have some weird exception when i try to load my jsp page with the
the simple tag
im geting :

org.apache.jasper.JasperException: File "/myTLD" not found


but all the files are there in the right place :
the jsp file is under "myApp" dir ( from where all the other jsp's running)
the taglib file is under WEB-INF
and the java class also under WEB-INF/classes dir
in the main web.xml i did add the Deployment Descriptor

<display-name>template</display-name>
<taglib>
<taglib-uri>/myTLD</taglib-uri>
<taglib-location>/WEB-INF/taglib.tld</taglib-location>
</taglib>
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!