• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Problem with Custom Tags

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Am stuck with Tag Libraries. the engine shows me 'not found' error. I havs follwed the following steps :

1) I hav created a SimpleTag.class and stored it in /webapps/root/egPM/WEB-INF/classes/.
2) Have created a TLD and stored it in /webapps/root/egPM/WEB-INF/.
The code in the TLD is :

<?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">;

<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>MyFirstTag</shortname>
<info>My tag library descriptor file</info>

<tag>
<name>SimpleTag</name>
<tagclass>SimpleTag</tagclass>
</tag>
</taglib>

3) in the /webapps/root/egPM/WEB-INF/web.xml file I hav added the following code :

<?xml version="1.0" encoding="ISO-8859-1"?>

<!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>
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<taglib>
<taglib-uri>/myTLD</taglib-uri>
<taglib-location>/WEB-INF/taglib.tld</taglib-location>
</taglib>
</web-app>

4) I hav created a simple jsp file to access the tags and hav placed it at :
/webapps/egPM/AccessingCustomTags.jsp

The code is as follows :
<html>
<head><title>Displaying a CustomTag</title></head>
<body>
<%@ taglib uri="/myTLD" prefix="myTags" %>

<myTags:SimpleTag></myTags:SimpleTag>
</body>
</html>



But when i run this file, an error is displayed saying /myTLD doesnt exist. I hav checked with a couple of books and followed exactly as they hav mentioned but to no avail. the error persists.....

Thnkz in advance for the help.

Paromita.
SCJP.
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
There seems to be different paths set at different places in your taglib,web.xml and in the jsp too..

1. Hope your java class doesnt have any package. its just simpleTag.class.
if not ,then you need to give the full package structure for ur class.
<tag>
<name>Packagexxx.SimpleTag</name>
<tagclass>SimpleTag</tagclass>
</tag>
</taglib>

2. You have your tld file in webapps/root/egPM/WEB-INF folder .
so the corresponding jsp too should be under webapps/root/egPM/ folder.isnt it ?

Also in your web.xml i dont think you need to give the relative path for the TLD. Remove the '/' before the TLD taglib-uri.

<web-app>
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<taglib>
<taglib-uri>myTLD</taglib-uri>
<taglib-location>/WEB-INF/taglib.tld</taglib-location>
</taglib>
</web-app>

and also your jsp should not be at /webapps/egPM/AccessingCustomTags.jsp

but /webapps/root/egPM/AccessingCustomTags.jsp .

and the taglib be
<%@ taglib uri="myTLD" prefix="myTags" %>

test out with these changes!
 
paromitabanerjee mukerjibanerjee
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Thankz.... I tried out the suggestion. but now it displays the following error :

org.apache.jasper.JasperException: File "/egPM/myTLD" not found


What else shld i change ?

Thnkz in advance.

Paromita
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic