Fala Pessoal,
seguinte, estou começando a estudar tags personalizadas, porém estão ocorrendo erros estranhos.
criei os seguintes arquivos:
exemplo1.java:
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
 
public class exemplo1 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();
}
}
 
taglib.tld:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
 
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>mytag</short-name>
<tag>
<name>mytag</name>
<tag-class>exemplo1</tag-class>
</tag>
 
</taglib>
 
web.xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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>
<taglib>
<taglib-uri>/myTLD</taglib-uri>
<taglib-location>/WEB-INF/taglib.tld</taglib-location>
</taglib>
</web-app>
 
simple.jsp:
<%@ taglib uri="/myTLD" prefix="easy"%>
<easy:mytag/>
 
os arquivos web.xml e taglib.tld estão em WEB-INF
e o exemplo1.class gerado em WEB-INF/classes
 
qd dei o startup no tomcat, a seguinte mensagem de erro apareceu duplamente:
org.xml.sax.SAXParseException: Element type "tlib-version" must be declared.
Não entedi o que aconteceu, uma vez que fiz tudo conforme o livro!
Aguardo qq tipo de ajuda
Igor P. Simões

Reply via email to