Hi, I'm having trouble identifying and understanding this error (this is part of exercise 9-3 from the Murach JSP/servlets book). I don't believe I have a missing uri attribute, as my tag doesn't have any attributes. Below, I provide the error message followed by three relevant files. I would greatly appreciate whatever help you can provide.
Thank you in advance for your assistance! - John
=====================
The Error:
org.apache.jasper.JasperException: /users.jsp(4,0) Taglib directive: Mandatory attribute uri missing
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:49)
etc.....
=====================
FILE: user.jsp
<%@ page import="data.UserIO, java.util.Vector" %>
<% Vector emails=UserIO.readRecords("..[path]/etc/UserEmails.txt");
session.setAttribute("emails", emails);
%>
<%@ taglib url="..[path]/tlds/murach.tld" prefix="mma" %>
<mma:emails>
<tr>
<td><%= pageContext.getAttribute("firstName") %></td>
<td><%= pageContext.getAttribute("lastName") %></td>
<td><%= pageContext.getAttribute("emailAddress") %></td>
</tr>
</mma:emails>
========================
FILE: murach.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>
<tlibversion>1.0</tlibversion>
<jspversion>1.2</jspversion>
<shortname></shortname>
<info>The tag library for the murach applications</info>
<tag>
<name>emails</name>
<tagclass>tags.UserEmailTag</tagclass>
<bodycontent>JSP</bodycontent>
</tag>
=======================================
FILE: UserEmailTag.java
package tags;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.util.*;
import business.User;
import data.UserIO.*;
public class UserEmailTag extends BodyTagSupport{
private Vector emails;
private int count;
private User email;
// Get vector and skip the body if the vector is empty.
public int doStartTag(){
emails = (Vector)(pageContext.findAttribute("emails"));
if (emails.size() <= 0){
return SKIP_BODY;
}
else{
return EVAL_BODY_BUFFERED;
}
}
// Evaluate the body and add the data for the first vector element
// to the bodyContent object.
public void doInitBody(){
count = 0;
email = (User) emails.get(count);
pageContext.setAttribute("firstName", email.getFirstName());
pageContext.setAttribute("lastName", email.getLastName());
pageContext.setAttribute("emailAddress", email.getEmailAddress());
count++;
}
// Evaluate the body again and add the data
// for the other vector elements to the bodyContent object.
// Then, write the data of the bodyContent object to the JSP.
public int doAfterBody() throws JspException{
try{
if (count < emails.size()){
email = (User) emails.get(count);
pageContext.setAttribute("firstName", email.getFirstName());
pageContext.setAttribute("lastName", email.getLastName());
pageContext.setAttribute("emailAddress", email.getEmailAddress());
count++;
return EVAL_BODY_AGAIN;
}
else{
JspWriter out = bodyContent.getEnclosingWriter();
bodyContent.writeOut(out);
return SKIP_BODY;
}
}
catch(IOException ioe){
System.err.println("IOException doAfterBody: " + ioe);
return SKIP_BODY;
}
}
}
============================
[ April 12, 2005: Message edited by: John Smithson ]