Ver Mensaje Individual
  #9 (permalink)  
Antiguo 16/09/2004, 13:32
Avatar de hugo777
hugo777
 
Fecha de Ingreso: enero-2002
Ubicación: Lima, Perú
Mensajes: 757
Antigüedad: 22 años, 3 meses
Puntos: 1
Hola jmontoya, ya lo probe y a mi si me funcionó, le hice por ahí algunos cambios en los nombres, pero me parece a mí que tus descriptores web.xml y simple.tld tenía algunas etiquetas en un orden distinto y eso podía causar que no reconociera a los tags.

Como yo lo probé desde el Sun ONE 4 , me permitió compilarlo y verificarlo que funcionara correctamente en TOMCAT, antes de hacer el deploy en JBoss.

Mi versión de JBoss es: 3.2.5(200406251954)

Te muestro los nuevos archivos:

1) Clase tags.SimpleTag :

package tags;

import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.IOException;

public class SimpleTag extends TagSupport {

/* Tag Attributes */
protected String color = "#000000";
protected String message = "Hello World!";

/* Process Start Tag */
public int doStartTag() throws JspTagException {
try {
JspWriter out = pageContext.getOut();
out.println("<font color=\"" + color + "\">");
out.println(message);
out.println("</font>");
}
catch (IOException e) {
throw new JspTagException(e.toString());
}
return SKIP_BODY;
}

/* Process End Tag */
public int doEndTag() throws JspTagException {
return EVAL_PAGE;
}

/* Attribute Accessor Methods */
public String getColor() {
return color;
}

public void setColor(String _color) {
color = _color;
}

public String getMessage() {
return message;
}

public void setMessage(String _message) {
message = _message;
}
}

2) Archivo prueba.jsp
<%@taglib uri="/simple" prefix="ex" %>
<html>
<head>
<title>Simple Tag Example</title>
</head>

<body>

<center>
<ex:SimpleTag color="#008000" message="This is a very, very, very simple tag!" />
</center>

</body>
</html>

3) Tag Library Descriptor: simple.tld :

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>simpleTag</short-name>
<uri>/simpleTag</uri>
<description>Tag library to support the examples in Chapter 4</description>
<tag>
<name>SimpleTag</name>
<tag-class>tags.SimpleTag</tag-class>
<body-content>empty</body-content>
<attribute>
<name>color</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>String</type>
</attribute>
<attribute>
<name>message</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>String</type>
</attribute>
</tag>
</taglib>

4) Web descriptor: web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<session-config>
<session-timeout>720</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>login.htm</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/simple</taglib-uri>
<taglib-location>/WEB-INF/tlds/simple.tld</taglib-location>
</taglib>
</web-app>



5. Estructura de crapetas archivos:

[ ] pruebaTagswar
|
--prueba.jsp
|
|--[] WEB-INF
|
--web.xml
|
--[ ]classes
|
| --tags
| -- | -- SimpleTag.java
|
--[ ]lib
|
|
--[ ] tlds
|
--simple.tld



Como te das cuenta, casí no le e hecho cambios y funciona. Toma como ejemplo el orden de las etiquetas en los archivos descriptores, como te envio. Ahora si aun asi no funciona bajata la version 3.2.5 de Jboss que es la que yo tengo.
__________________
Saludos,

H@C..