aspose file tools*
The moose likes JSP and the fly likes Error Displaying Custom Tags in JSp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Error Displaying Custom Tags in JSp" Watch "Error Displaying Custom Tags in JSp" New topic
Author

Error Displaying Custom Tags in JSp

Niyali Kaul
Greenhorn

Joined: Apr 14, 2006
Posts: 1
hi i am using Tomacat 5.0.28 i have a problem while displaying the Custom tags in JSP.
The errors i get are


org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: XML parsing error on file /WEB-INF/tlds/mytaglib.tld
org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:249)
org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:220)
org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:475)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:417)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1539)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



My tld file is ----> The file is stored in /WEB-INF/tlds/mytglib.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">

<!-- a tag library descriptor -->

<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>first</shortname>
<uri>/WEB_INF/tlds</uri>
<info>A simple tab library for the
examples</info>

<tag>
<name>hello</name>
<tagclass>happy.tag.HelloTag</tagclass>
<bodycontent>empty</bodycontent>
<info>Say Hi</info>
</tag>
</taglib>

JSP FILE ---->

<%@ taglib uri="/WEB-INF/tlds/mytaglib.tld" prefix="first" %>
<HTML>
<HEAD>
<TITLE>Hello Tag</TITLE>
</HEAD>

<BODY bgcolor="#ffffcc">

<B>My first tag prints</B>:

<first:hello/>

</BODY>
</HTML>

web.xml file --->


<taglib>
<taglib-uri>/WEB-INF/tlds</taglib-uri>
<taglib-location>/WEB-INF/tlds/mytaglib.tld</taglib-location>
</taglib>






Tag File -->It is saved in directory /WEB-INF/classes/happy/tag/HelloTag.java

package tag;

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

public class HelloTag implements Tag {
private PageContext pageContext;
private Tag parent;

public HelloTag() {
super();
}

public int doStartTag() throws JspException {
try {
pageContext.getOut().print("This is my first tag!");
} catch (IOException ioe) {}
return SKIP_BODY;
}

public int doEndTag() throws JspException {
return SKIP_PAGE;
}

public void release() {
}

public void setPageContext(PageContext
pageContext) {
this.pageContext = pageContext;
}

public void setParent(Tag parent) {
this.parent = parent;
}

public Tag getParent() {
return parent;
}
}



Please help me out .
can't figure out the problem
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

The uri attribute in the taglib declaration in the jsp should have the value defined in the <taglib-uri> tag in web.xml. In your posting it has the value defined in the <taglib-location> tag.

ram.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Don't do anything. Simply use, <%@ taglib uri="/WEB-INF/tlds" prefix="first" %> in your jsp.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

XML parsing error on file /WEB-INF/tlds/mytaglib.tld


You have a syntax error somewhere in your tld.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: Error Displaying Custom Tags in JSp