aspose file tools*
The moose likes JSP and the fly likes Taglib directive: Mandatory attribute uri missing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Taglib directive: Mandatory attribute uri missing" Watch "Taglib directive: Mandatory attribute uri missing" New topic
Author

Taglib directive: Mandatory attribute uri missing

John Smithson
Greenhorn

Joined: Apr 12, 2005
Posts: 2
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 ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Look at these two lines very very carefully:

Taglib directive: Mandatory attribute uri missing

<%@ taglib url="..[path]/tlds/murach.tld" prefix="mma" %>


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
John Smithson
Greenhorn

Joined: Apr 12, 2005
Posts: 2
Thanks Bear,
I'm going to go put my head through a wall.

- John
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Reminds me of the time I spent hours trying to find out what was up with a section of code only to have someone walk up behind me and say "what's that semi-colon doing there?".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Taglib directive: Mandatory attribute uri missing