JSP (Java Server Page) - problema con Custom Tags

 
Vista:

problema con Custom Tags

Publicado por Oscar (21 intervenciones) el 11/09/2007 22:18:40
Saludos

Estoy aprendiendo a usar los custom tags y no logor ahcer que funcione mi ejemplo. El archivo java compila prefectamente, pero al correr la aplicacion JSP me sale el siguiente Error:

''Unable to initialize TldLocationsCache"

Trabajo con Tomcat 5
y mi ubicacion de los archivos es el siguiente:

Mi aplicacion/WEB-INF/tlds/oreilly.tld

Mi Aplicacion//WEB-INF/classes/oreilly/tags/ejemplos/Hello.class

Mi aplicacion/Saluda.jsp

saludos y gracias de antemano.

les anexo mis archivos de configuracion.

------------------------------------------------------------------------------
oreilly.tld

<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">

<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>sample</shortname>
<uri> </uri>
<info>OReilly Sample Tag library</info>


<tag>
<name>hello</name>
<tagclass>oreilly.tags.ejemplos.Hello</tagclass>

<bodycontent>empty</bodycontent>
<description>Imprime un mensaje</description>


<attribute>
<name>name</name>
<required>false</required>
<rtexpvalue>false</rtexpvalue>
</attribute>
</tag>

</taglib>

-------------------------------------------------------------------------------

Saluda.jsp

<%@taglib uri="/oreilly.tld" prefix="or" %>

<html>
<head>
<title>Your Standard Hello World Demo</title>
</head>
<body bgcolor="#ffffff">
<hr />
<or:hello name="Sue"/>
<br />

<hr />
</body>
</html>
-------------------------------------------------------------------------------------

y el java es :

package oreilly.tags.ejemplos;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class Hello extends TagSupport {
private String name=null;

public void setName(String value){
name = value;
}

public String getName(){
return(name);
}

public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
out.println("<table border=\"1\">");
if (name != null)
out.println("<tr><td> Hello " + name + " </td></tr>");
else
out.println("<tr><td> Hello World </td></tr>");
} catch (Exception ex) {
throw new Error("All is not well in the world.");
}
// Must return SKIP_BODY because we are not supporting a body for this
// tag.
return SKIP_BODY;
}

public int doEndTag(){
try {
JspWriter out = pageContext.getOut();
out.println("</table>");
} catch (Exception ex){
throw new Error("All is not well in the world.");
}
return SKIP_PAGE; // <-----------------esta linea agregada por mi, porque no la tenia el //ejemplo original
}
}

--------------------------------------------------------------------------------------------------------------------------
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Olvide esto...

Publicado por Oscar (21 intervenciones) el 11/09/2007 22:31:23
Aqui anexo lo que me falto del mensaje anterior...

Este es el correcto oreilly.tld

<?xml version="1.0" encoding="UTF-8"?>

<!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>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>sample</shortname>
<uri> </uri>
<info>OReilly Sample Tag library</info>

<tag>
<name>hello</name>
<tagclass>oreilly.tags.ejemplos.Hello</tagclass>

<bodycontent>empty</bodycontent>
<description>Imprime un mensaje</description>
<display-name>Hello</display-name>


<attribute>
<name>name</name>
<required>false</required>
<rtexpvalue>false</rtexpvalue>
</attribute>
</tag>

</taglib>

-----------------------------------------------------------------------------------------------------------------

El web.xml lo deje asi....

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>

<!-- REGISTRO DE LAS ETIQUETAS JAVA (JAVA TAG LIBRARY)-->

<taglib>
<taglib-uri>
/oreilly.tld
</taglib-uri>
<taglib-location>
/WEB-INF/tlds/oreilly.tld
</taglib-location>
</taglib>

<!-- FIN REGISTRO DE LAS ETIQUETAS JAVA (JAVA TAG LIBRARY)-->


</web-app>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar