• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Taglib directive: Mandatory attribute uri missing

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at these two lines very very carefully:

Taglib directive: Mandatory attribute uri missing

<%@ taglib url="..[path]/tlds/murach.tld" prefix="mma" %>
 
John Smithson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear,
I'm going to go put my head through a wall.

- John
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?".
 
reply
    Bookmark Topic Watch Topic
  • New Topic