• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Element type "tlibversion" must be declared

 
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you look at the DTD for the tld file?
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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">
 
ben josh
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
It runs on an internal combustion engine. This ad does not:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic