I just noticed this disucssion and what I find here has me totally
confused!!!

The <taglib-uri> denotes a virtual mapping to the file in the
<taglib-location> tag.

You use the <taglib-uri> as the reference on a JSP page.

The concept is the same used for servlet mapping. You defina e servlet with
a name, you use this name to create a mapping. The mapping then goes back
from the servlet name to the servlet class to get the class:

url-mapping -> servletName -> servlet class

uri -> uri-location -> tag

The URI doesn't need to be absolute, it can be called anything you want
provided it links up to the TLD file referenced under the same name as in
the web.xml file.

so:
<taglib>
        <taglib-uri>personalTags</taglib_uri>
        <taglib-location>/WEB-INF/tlds/myOwnTags.tld</taglib-location>
</taglib>

You then reference this as:
<%@ taglib uri="personalTags" prefix="itWorks"%>

In theory the taglib-location can point to any location (eg
http://www.home.com/tags/tag.tld,
http://home.org/coolTags/numericProcessTags.tld) but the <taglib-uri> is
what identifies the taglib entry.

If you want the servlet example:

<servlet>
        <servlet-name>theBestServletEver</servlet-name>
        <servlet-class>com.home.servlets.BestServlet</servlet-class>
</servlet>
<servlet-mapping>
        <servlet-name>theBestServletEver</servlet-name>
        <url-mapping>/myBest/servletEver/*</url-mapping>
</servlet-mapping>


The <taglib-uri> is the same as the <servlet-name> it just identifies it for
use anywhere inside the web application.

The example below presented by Stefan:

        <%@ taglib uri="/WEB-INF/jdbc.tld" prefix="sql"%>

is syntactically correct for an absolute uri but therefore does not really
need declaration in the web.xml file. Kind of pointless if you have a
dynamic system that may require the reference to be updated across n number
of pages. ie if you change the tld filename (say to jdbcExt.tld) you would
need to go through each page that references this file and update it. With
the web.xml reference, it only needs to be updated once.

Has this made it any clearer for those who didn't follow the comments below?
Sorry if I've iterated much of what may have been saif (and no offense
intended) but I thought it would be easier presenting the Servlet API
standard (which many seem to overlook).

Cheers,
Anthony Ikeda
Web Application Developer,
Proxima Technology
Sydney
Australia



-----Original Message-----
From: Morgan Delagrange [mailto:[EMAIL PROTECTED]]
Sent: Saturday, 14 April 2001 4:42 AM
To: [EMAIL PROTECTED]
Subject: Re: AW: Newbie Question


Yup, that's the real problem.  Sorry.

--- Stefan Riegel <[EMAIL PROTECTED]> wrote:
> Hello Morgan, hello Amar,
>
> isn't their another error in the code of Amar?
>
> If I understood the thing right (I am newbie too),
> the "taglib-uri-Tag"
> defines a sort of placeholder for the real location,
> which is defined in the
> "taglib-location-Tag".
>
> Amar wrote
>
<taglib-uri>http://***java***.apache.org/taglibs/jdbc</taglib-uri>
> but
> refers to ***jakarta***.apache.org/taglibs/jdbc in
> the JSP-Page.
>
> The JSP Container doesn't find the specified URI in
> the web.xml and takes
> the URI itself (http://jakarta.apache...) as the
> default location for the
> tag library descriptor file. Because their isn't the
> TLD, the container
> produces the error.
>
> I think it is less complicated, if one uses the
> default location like
>    <%@ taglib uri="/WEB-INF/jdbc.tld" prefix="sql"
> %>
> for learning or testing purpose. I use some Jakarta
> Taglibs without any
> <taglib>-Entry in the web.xml.
>
>
> Regards
> Stefan Riegel
>
>
> > -----Ursprungliche Nachricht-----
> > Von: Morgan Delagrange [mailto:[EMAIL PROTECTED]]
> > Gesendet: Donnerstag, 12. April 2001 21:17
> > An: [EMAIL PROTECTED]
> > Betreff: Re: Newbie Question
> >
> >
> > I would think that would work, but you might want
> to
> > try this in your web.xml instead:
> >
> >   <taglib>
> >
> >
>
<taglib-uri>http://java.apache.org/taglibs/jdbc</taglib-uri>
> >
> >     <taglib-location>jdbc.tld</taglib-location>
> >   </taglib>
> >
> > Also, as a point of information, this line
> shouldn't
> > be necessary if you only access the database via
> the
> > tag library:
> >
> > > <%@ page language="java" import="java.sql.*,
> > > oracle.jdbc.driver.*" %>
> >
> > --- Dummy Amar <[EMAIL PROTECTED]>
> > wrote:
> > > Hi,
> > >
> > > I downloaded the JDBC taglib directory and
> following
> > > the direction copied
> > > the jdbc.tld file under the /WEB-INF directory
> and
> > > jdbc.jar under
> > > /WEB-INF/lib directory. I also created an entry
> in
> > > the /WEB_INF/web.xml
> > > like
> > >    <taglib>
> > >         <taglib-uri>
> > >
> http://java.apache.org/taglibs/jdbc</taglib-uri>
> > >
> > >
> <taglib-location>/WEB-INF/jdbc.tld</taglib-location>
> > >     </taglib>
> > >
> > > After that I tried the following JSP page
> > >
> > > <%@ page language="java" import="java.sql.*,
> > > oracle.jdbc.driver.*" %>
> > > <%@ taglib
> > > uri="http://jakarta.apache.org/taglibs/jdbc"
> > > prefix="sql" %>
> > >
> > > <%-- open a database connection --%>
> > > <sql:connection id="conn1">
> > >
> > >
> >
>
<sql:url>jdbc:oracle:thin:@oak.stgeorgeconsulting.com:1521:ser
> > verName</sql:url>
> > >
> > >
> >
>
<sql:driver>oracle.jdbc.driver.OracleDriver</sql:driver>
> > >
> > >   <%-- optional --%>
> > >   <sql:userId>Usernmae</sql:userId>
> > >
> > >   <%-- optional --%>
> > >   <sql:password>password</sql:password>
> > > </sql:connection>
> > >
> > >
> > >
> > > <%-- close a database connection --%>
> > > <sql:closeConnection conn="conn1"/>
> > >
> > > I am receiving the following error message
> > >
> > > org.apache.jasper.JasperException: Unable to
> open
> > > taglibrary
> > > http://jakarta.apache.org/taglibs/jdbc : Could
> not
> > > locate TLD
> > > META-INF/taglib.tld
> > >   at
> > >
> >
>
org.apache.jasper.compiler.JspParseEventListener.handleDirecti
> > ve(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.loadIfN
> > ecessary(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(ServletWra
> > pper.java:503)
> > >   at
> > >
> >
>
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> > >   at
> > >
> >
>
org.apache.tomcat.service.http.HttpConnectionHandler.processCo
> > nnection(HttpConnectionHandler.java:160)
> > >   at
> > >
> >
>
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEnd
> > point.java:338)
> > >   at java.lang.Thread.run(Thread.java:484)
> > >
> > > Please help.
> > >
> > > Thanks in advance
> > > Amar Das
> > >
> >
> >
> > =====
> > Morgan Delagrange
> > Britannica.com
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get email at your own domain with Yahoo! Mail.
> > http://personal.mail.yahoo.com/
> >
>


=====
Morgan Delagrange
Britannica.com

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/

Reply via email to