puntito
Programmer
- Mar 22, 2006
- 18
I have to learn how to create custom tags.
I am using MyEclipse.
I create the class
Then the tag library
And the jsp page
But I'm not sure, why it doesnt work
Could somebody give me any advise, please??
Thanks!!
I am using MyEclipse.
I create the class
Code:
public class etiqts extends TagSupport {
public etiqts() {
super();
// TODO Auto-generated constructor stub
}
public int doStartTag() throws JspException {
try {
pageContext.getOut().print("Esta es mi etiqueta");
} catch (IOException e){
throw new JspException("Error al enviar al cliente" +
e.getMessage());
}
return SKIP_BODY;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
public void release(){
}
Then the tag library
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"[URL unfurl="true"]http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">[/URL]
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>tagFile</shortname>
<uri></uri>
<info>Etiquetas de ejemplo</info>
<tag>
<name>etiquets</name>
<tagclass>etiqts</tagclass>
<bodycontent>empty</bodycontent>
<info>Saludo</info>
</tag>
</taglib>
And the jsp page
Code:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="tagFile.tld" prefix="tagFile" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'probandoTag.jsp' starting page</title>
</head>
<body>
This is my JSP page with a tag. <br>
<tagFile:etiquets/>
</body>
</html>
But I'm not sure, why it doesnt work
Could somebody give me any advise, please??
Thanks!!