Link to home
Start Free TrialLog in
Avatar of Richards
Richards

asked on

Unable to locate tag library

The test.tld file is in /WEB-INF/tld/ but I am getting the below error

JSPG0047E: Unable to locate tag library for uri /WEB-INF/tld/test.tld
Avatar of radarsh
radarsh

Hi Richards,

You need to have the uri mapped to the location in your web.xml.

  <taglib>
    <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
  </taglib>

The above is for servlet version 2.3 and below.

In 2.4, there is no such tag as taglib in web.xml. All you have to give then, is the URI
which you can find in the .tld file itself.
________
radarsh
ASKER CERTIFIED SOLUTION
Avatar of radarsh
radarsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richards

ASKER

I am not using struts and here is the web xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="Testap">

<taglib>
      <taglib-uri>testTags</taglib-uri>
      <taglib-location>/WEB-INF/tld/test.tld</taglib-location>
 </taglib>
Richards,

My last post should have clarified your doubt!

________
radarsh
You should be using

<%@ taglib prefix="test" uri="testTags" %>


________
radarsh
In the JSP I am using as below
<%@ taglib uri="test.tld" prefix="cpt" %>

Please let me know how this prefix cpt  or prefix = "test" in your case will be related
Richards,

You can give any prefix... That doesn't matter at all. The only thing is you have to literally
*prefix* the prefix.

I mean, you have to use <prefix:tagname...
In your case <cpt:whatever

Well, your URI is wrong. You *should* give what you define in your
web.xml. I see from you previous post that it is testTags.

So, change that to

<%@ taglib uri="testTags" prefix="cpt" %>

________
radarsh
On the other machines
<%@ taglib uri="/WEB-INF/tld/test.tld" prefix="cpt" %> is working and on my application server it is not working . So what is the difference in

<%@ taglib uri="testTags" prefix="cpt" %>

and

<%@ taglib uri="/WEB-INF/tld/test.tld" prefix="cpt" %>

You mean the same code works on other machines?
Bleak Possibility!

Burn this into your brain:

*** All are legal provided you have the uri mapped to the proper tld file in your web.xml ***

URI is like a key. That's all. And to make sure it is unique, they follow that convention
of naming them like websites. But it is not mandatory. You can give anything and it'll work.

________
radarsh
Also read the last two sentences of my first post carefully.

________
radarsh
Thanks but now what I need to do as the error is still coming
Then I guess your tld file is not proper.

Refer http://java.sun.com/developer/Books/javaserverpages/cservletsjsp/chapter14.pdf

for a complete discussion in case you are trying out tld creation yourself.

________
radarsh
No they are not new tlds The same tlds are working in WSAD and when moved to RAD it is giving that error
Are you sure you created a Web 2.3 project in RAD? If you have created a 2.4 one, you have to
give the uri present in the tld file itself as i said earlier.
in the projects properties the level shows

J2EE 1.3 includes Connector Architecture Specification level 1.0, Servlet Specification level 2.3, JSP Specification level 1.2, and EJB Specification level 2.0.