[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglibs-user
Subject:    Re: Unable to open taglibrary csajsp-taglib.tld : Parse Error in the tag
From:       Pierre Delisle <pierre.delisle () sun ! com>
Date:       2000-11-24 14:04:52
[Download RAW message or body]

Terry,

You get this error because the "servlet" tag in your web.xml is not properly
positioned.

If using servlet 2.2, you must obey the following order:
[from the web.xml DTD]

<!ELEMENT web-app (icon?, display-name?, description?, distributable?,
context-param*, servlet*, servlet-mapping*, session-config?,
mime-mapping*, welcome-file-list?, error-page*, taglib*,
resource-ref*, security-constraint*, login-config?, security-role*,
env-entry*, ejb-ref*)>

This was "ignored" in older releases of tomcat.

    -- Pierre


> Terry Hanks wrote:
> 
> I am having trouble getting started with taglibs, and would appreciate any help if \
> someone has seen this problem before. 
> I am trying to use the first taglib example from chapter 14 of the book \
> "Coreservelts and JSP" with Tomcat 3.1. 
> I get the parse error shown below.  The example that I am trying to use consists of \
> the following files in the following directories: 
> 
> 
> SimpleExample.jsp in htdocs
> 
> csajsp-taglib.tld in htdocs
> 
> ExampleTag.class in htdocs/WEB-INF/classes/coreservlets/tags
> 
> 
> 
> I list the following information below:
> 
> - the error in the browser
> 
> - source for SimpleExample.jsp
> 
> - csajsp-taglib.tld in htdocs
> 
> - ExampleTag.java
> 
> Error: 500
> 
> Location: /SimpleExample.jsp
> 
> Internal Servlet Error:
> 
> org.apache.jasper.JasperException: Unable to open taglibrary csajsp-taglib.tld : \
> Parse Error in the tag library descriptor: Element "web-app" does not allow \
> "servlet" here. at \
> org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEventListener.java:672)
>  at org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingListener.java:116)
>  at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:215)
> at org.apache.jasper.compiler.Parser.parse(Parser.java:1073)
> at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
> at org.apache.jasper.compiler.Parser.parse(Parser.java:1034)
> at org.apache.jasper.compiler.Compiler.compile(Compiler.java:182)
> at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
> at org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:149)
>  at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:161)
>  at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
> at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:167)
>  at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
> at java.lang.Thread.run(Thread.java:484)
> 
> 
> 
> Source for SimpleExample.jsp:
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> 
> <!--
> 
> Illustration of very simple JSP custom tag.
> 
> Taken from Core Servlets and JavaServer Pages
> 
> from Prentice Hall and Sun Microsystems Press,
> 
> http://www.coreservlets.com/.
> 
> &copy; 2000 Marty Hall; may be freely used or adapted.
> 
> -->
> 
> <HTML>
> 
> <HEAD>
> 
> <%@ taglib uri="csajsp-taglib.tld" prefix="csajsp" %>
> 
> <TITLE><csajsp:example /></TITLE>
> 
> <LINK REL=STYLESHEET
> 
> HREF="JSP-Styles.css"
> 
> TYPE="text/css">
> 
> </HEAD>
> 
> <BODY>
> 
> <H1><csajsp:example /></H1>
> 
> <csajsp:example />
> 
> </BODY>
> 
> </HTML>
> 
> 
> 
> 
> 
> csajsp-taglib.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>
> 
> <!-- after this the default space is
> 
> "http://java.sun.com/j2ee/dtds/jsptaglibrary_1_2.dtd"
> 
> -->
> 
> <tlibversion>1.0</tlibversion>
> 
> <jspversion>1.1</jspversion>
> 
> <shortname>csajsp</shortname>
> 
> <!-- ** CHANGED FROM "urn" TO "uri" IN TOMCAT 3.1 ** -->
> 
> <uri></uri>
> 
> <info>
> 
> A tag library from Core Servlets and JavaServer Pages,
> 
> http://www.coreservlets.com/.
> 
> </info>
> 
> <!--
> 
> <tag>
> 
> The name (after prefix) tag will have in JSP code
> 
> <name>example</name>
> 
> The actual class implementing tag. In
> 
> Tomcat 3.1 beta, it MUST be in a package.
> 
> <tagclass>coreservlets.tags.ExampleTag</tagclass>
> 
> Descriptive information about tag.
> 
> <info>Simplest example: inserts one line of output</info>
> 
> One of three values describing what goes between
> 
> start and end tag.
> 
> empty: no body
> 
> JSP: body that is evaluated by container normally,
> 
> then possibly processed by tag
> 
> tagdependent: body is only processed by tag;
> 
> JSP in body is not evaluated.
> 
> ** NOTE: TOMCAT 3.1 FINAL DOES NOT SUPPORT BODYCONTENT **
> 
> ** THE BETA SUPPORTED IT, AND IT IS PART OF SPEC, BUT... **
> 
> <bodycontent>empty</bodycontent>
> 
> </tag>
> 
> -->
> 
> <tag>
> 
> <name>example</name>
> 
> <tagclass>coreservlets.tags.ExampleTag</tagclass>
> 
> <info>Simplest example: inserts one line of output</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>empty</bodycontent> -->
> 
> </tag>
> 
> <tag>
> 
> <name>simplePrime</name>
> 
> <tagclass>coreservlets.tags.SimplePrimeTag</tagclass>
> 
> <info>Outputs a random 50-digit prime.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>empty</bodycontent> -->
> 
> </tag>
> 
> <tag>
> 
> <name>prime</name>
> 
> <tagclass>coreservlets.tags.PrimeTag</tagclass>
> 
> <info>Outputs a random N-digit prime.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>empty</bodycontent> -->
> 
> <attribute>
> 
> <name>length</name>
> 
> <required>false</required>
> 
> </attribute>
> 
> </tag>
> 
> <tag>
> 
> <name>heading</name>
> 
> <tagclass>coreservlets.tags.HeadingTag</tagclass>
> 
> <info>Outputs a 1-cell table used as a heading.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>JSP</bodycontent> -->
> 
> <attribute>
> 
> <name>bgColor</name>
> 
> <required>true</required> <!-- bgColor is required -->
> 
> </attribute>
> 
> <attribute>
> 
> <name>color</name>
> 
> <required>false</required>
> 
> </attribute>
> 
> <attribute>
> 
> <name>align</name>
> 
> <required>false</required>
> 
> </attribute>
> 
> <attribute>
> 
> <name>fontSize</name>
> 
> <required>false</required>
> 
> </attribute>
> 
> <attribute>
> 
> <name>fontList</name>
> 
> <required>false</required>
> 
> </attribute>
> 
> <attribute>
> 
> <name>border</name>
> 
> <required>false</required>
> 
> </attribute>
> 
> <attribute>
> 
> <name>width</name>
> 
> <required>false</required>
> 
> </attribute>
> 
> </tag>
> 
> <tag>
> 
> <name>debug</name>
> 
> <tagclass>coreservlets.tags.DebugTag</tagclass>
> 
> <info>Includes body only if debug param is set.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>JSP</bodycontent> -->
> 
> </tag>
> 
> <tag>
> 
> <name>filter</name>
> 
> <tagclass>coreservlets.tags.FilterTag</tagclass>
> 
> <info>Replaces HTML-specific characters in body.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>JSP</bodycontent> -->
> 
> </tag>
> 
> <tag>
> 
> <name>repeat</name>
> 
> <tagclass>coreservlets.tags.RepeatTag</tagclass>
> 
> <info>Repeats body the specified number of times.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>JSP</bodycontent> -->
> 
> <attribute>
> 
> <name>reps</name>
> 
> <required>true</required>
> 
> <!-- rtexprvalue indicates whether attribute
> 
> can be a JSP expression. -->
> 
> <rtexprvalue>true</rtexprvalue>
> 
> </attribute>
> 
> </tag>
> 
> <tag>
> 
> <name>if</name>
> 
> <tagclass>coreservlets.tags.IfTag</tagclass>
> 
> <info>if/condition/then/else tag.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>JSP</bodycontent> -->
> 
> </tag>
> 
> <tag>
> 
> <name>condition</name>
> 
> <tagclass>coreservlets.tags.IfConditionTag</tagclass>
> 
> <info>condition part of if/condition/then/else tag.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>JSP</bodycontent> -->
> 
> </tag>
> 
> <tag>
> 
> <name>then</name>
> 
> <tagclass>coreservlets.tags.IfThenTag</tagclass>
> 
> <info>then part of if/condition/then/else tag.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>JSP</bodycontent> -->
> 
> </tag>
> 
> <tag>
> 
> <name>else</name>
> 
> <tagclass>coreservlets.tags.IfElseTag</tagclass>
> 
> <info>else part of if/condition/then/else tag.</info>
> 
> <!-- TOMCAT 3.1 DOES NOT SUPPORT BODYCONTENT
> 
> <bodycontent>JSP</bodycontent> -->
> 
> </tag>
> 
> </taglib>
> 
> 
> 
> ExampleTag.java
> 
> package coreservlets.tags;
> 
> import javax.servlet.jsp.*;
> 
> import javax.servlet.jsp.tagext.*;
> 
> import java.io.*;
> 
> /** Very simple JSP tag that just inserts a string
> 
> * ("Custom tag example...") into the output.
> 
> * The actual name of the tag is not defined here;
> 
> * that is given by the Tag Library Descriptor (TLD)
> 
> * file that is referenced by the taglib directive
> 
> * in the JSP file.
> 
> * <P>
> 
> * Taken from Core Servlets and JavaServer Pages
> 
> * from Prentice Hall and Sun Microsystems Press,
> 
> * http://www.coreservlets.com/.
> 
> * &copy; 2000 Marty Hall; may be freely used or adapted.
> 
> */
> 
> public class ExampleTag extends TagSupport {
> 
> public int doStartTag() {
> 
> try {
> 
> JspWriter out = pageContext.getOut();
> 
> out.print("Custom tag example " +
> 
> "(coreservlets.tags.ExampleTag)");
> 
> } catch(IOException ioe) {
> 
> System.out.println("Error in ExampleTag: " + ioe);
> 
> }
> 
> return(SKIP_BODY);
> 
> }
> 
> }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic