tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Jones" <sc...@izio.com>
Subject Re: trying to make a custom jsp tag
Date Tue, 17 Oct 2000 17:06:01 GMT
Hi David,

You can put your TLD files anwhere -- I put mine in WEB-INF/tlds/

Then, you register the TLD in web.xml:

 <taglib>
        <taglib-uri>
            http://www.yourcompanyname.com/taglib/database
        </taglib-uri>
        <taglib-location>
           /WEB-INF/tlds/database.tld
        </taglib-location>
    </taglib>

Then, when you go to use your taglib, you have to refer to that same URI

<%@ taglib uri="http://www.yourcompanyname.com/taglib/database" prefix="sql"
%>

That should do it... :)  It took me a while to get it going, but it was well
worth it.  I ended up figuring it out by looking at the sample code in
webapps/examples/jsp/simpletag.  Take a look at that, and it's associated
web.xml file if you get stuck (the taglib for that example is in
WEB-INF/jsp).  Good luck!

-Scott

----- Original Message -----
From: "Harding, David" <dharding@Thomcomp.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Tuesday, October 17, 2000 9:33 AM
Subject: trying to make a custom jsp tag


> i am trying to make a custom tag under tomcat 3.1
>
> where am i supposed to put my tld file? (where in development, and where
> does it end up)
>
> what am i supposed to put in the web.xml under <taglib>....bleh
> bleh</taglib>?
>
> in my jsp file:  <%@ taglib uri="what here?"...... %>
>
>
> this is driving me crazy...nothing in tomcat docs or associated docs that
i
> can find that talk about the tomcat specific way to do tags.
>
> i tried to follow the steps in core servlets and javaserver pages (pretty
> good intro book) to make a custom tag, and i get bad results as follows:
>
> error printed to stderr of my shell that started tomcat:
>
> org.apache.jasper.JasperException: Parse Error in the tag library
> descriptor: Element "servlet" does not allow "init-param" here.
>         at org.apache.jasper.compiler.JspUtil.parseXMLDoc(JspUtil.java,
> Compiled Code)
>         at
>
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java
> , Compiled Code)
>         at
>
org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve
> ntListener.java, Compiled Code)
>         at
>
org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingList
> ener.java, Compiled Code)
>         at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java,
> Compiled Code)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java, Compiled
> Code)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java, Compiled
> Code)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java, Compiled
> Code)
>         at org.apache.jasper.compiler.Compiler.compile(Compiler.java,
> Compiled Code)
>         at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java,
> Compiled Code)
>         at
>
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspSe
> rvlet.java, Compiled Code)
>         at
>
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
> va, Compiled Code)
>         at
> org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java,
> Compiled Code)
>         at org.apache.jasper.runtime.JspServlet.service(JspServlet.java,
> Compiled Code)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java,
Compiled
> Code)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
> Compiled Code)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java,
Compiled
> Code)
>         at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
> onnectionHandler.java, Compiled Code)
>         at
> org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java,
> Compiled Code)
>         at java.lang.Thread.run(Thread.java, Compiled Code)
>
>
> error printed in webpage when trying to access jsp file:
>
> org.apache.jasper.JasperException: Unable to open taglibrary account.tld :
> Parse Error in the tag library descriptor: Element "servlet" does not
allow
> "init-param" here.
>         at
>
org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve
> ntListener.java, Compiled Code)
>         at
>
org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingList
> ener.java, Compiled Code)
>         at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java,
> Compiled Code)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java, Compiled
> Code)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java, Compiled
> Code)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java, Compiled
> Code)
>         at org.apache.jasper.compiler.Compiler.compile(Compiler.java,
> Compiled Code)
>         at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java,
> Compiled Code)
>         at
>
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspSe
> rvlet.java, Compiled Code)
>         at
>
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
> va, Compiled Code)
>         at
> org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java,
> Compiled Code)
>         at org.apache.jasper.runtime.JspServlet.service(JspServlet.java,
> Compiled Code)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java,
Compiled
> Code)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
> Compiled Code)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java,
Compiled
> Code)
>         at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
> onnectionHandler.java, Compiled Code)
>         at
> org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java,
> Compiled Code)
>         at java.lang.Thread.run(Thread.java, Compiled Code)


Mime
View raw message