• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

taglibs error

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,
I just started working on taglibs. As usual i started out with a set of errors. I am using
Tomcat 4.1 over Windows 98
I am not sure if i have the directory structure correct.
I created a sample directory under webapps and my application is called sample. I have the files as following
/Webapps
|---/Sample
|------/Web-Inf
| |--/classes
| | |-------HelloTag.class
| |--web.xml
| |--HelloTag.tld
|------Hello.jsp
Hello.jsp
===========
<%@ taglib uri="http://localhost:8080/sample" prefix="examples" %>
<html>
<head>
<title>First custom tag</title>
</head>
<body>
This is static output.
<p />
<i>
<examples:hello></examples:hello>
</i>
This is static output again.
</body>
</html>
Web.xml is as follows
=====================
<?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>Sample</display-name>
<description>
Welcome to Sample
</description>

<taglib>
<taglib-uri>/WEB-INF/HelloTag.tld</taglib-uri>
<taglib-location>/WEB-INF/HelloTag.tld</taglib-location>
</taglib>
</web-app>
HelloTag.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">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>examples</shortname>
<info>Simple example library.</info>
<tag>
<name>hello</name>
<tagclass>HelloTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>Simple example</info>
</tag>
</taglib>
I had a error free compile on the file HelloTag.class and the class name is HelloName.
The servlet container throws an Null Pointer Exception.
Any Pointers to why this occurs?
Thanks In Advance.
Prashanth Kalvala
 
Author
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can immediately see two problems:
1) The WEB-INF directory MUST be capitalised.
2) The taglib URI that you have used on your JSP does not match that declared in your web.xml
Try and resolve these issues and let us know if there are more problems
Cheers
Sam
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic