This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes A strange problem with jsp custom tag. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "A strange problem with jsp custom tag." Watch "A strange problem with jsp custom tag." New topic

A strange problem with jsp custom tag.

Bibhudutta Pradhan
Ranch Hand

Joined: Jun 24, 2011
Posts: 31

I create my project in eclipse, copy it and paste it in the C:\Tomcat 6.0\webapps .

I am trying to develop a simple jsp custom tag. The files i have used are as follows.

<%@ taglib
prefix="jspx" %>

Executing your first custom tag... <b><jspx:hello/></b>

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

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"

<uri> /WEB-INF/simpletags.tld </uri>
A simple sample tag library

Say hello.
package com;

import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;

public class HelloWorldTag extends TagSupport {

public int doStartTag()throws JspException
pageContext.getOut().print("Hello JSP tag World");
catch(IOException ioe)
throw new JspTagException("Error:IOException while writing to the user");
return SKIP_BODY;

I have been trying it since a week.
The problem is that as long as jsp-api.jar is under C:\Tomcat 6.0\webapps\myFirstCustomTag\WEB-INF\lib,
running index.jsp gives me following exception.

org.apache.jasper.JasperException: java.lang.NullPointerException

root cause



But when i remove the jsp-api.jar from C:\Tomcat 6.0\webapps\myFirstCustomTag\WEB-INF\lib,
the problem evaporates and the project runs normally. But WHY ? I cant understand .

Please help. Thanks in advance.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60774

You should never put jsp-api.jar or servlet-api.jar in WEB-INF/lib. It just fouls things up with hard-to-diagnose errors. These jar files are provided by the container and should never be put into your web apps.

And I'd also advice to use proper URIs for your taglibs. You can use anything you want, but not following conventions just makes things harder than they need to be.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

Both web.xml and simpletags.tld use the URI '/WEB-INF/simpletags.tld', but your JSP references 'WEB-INF/simpletags.tld'. Are you sure your JSP container sees those as equivalent?

In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
I agree. Here's the link:
subject: A strange problem with jsp custom tag.
Similar Threads
jsp custom tag issues
problem in Taglib in jsp
Custom Tag NOT Compiling
Error using custom tag
Problem while running JSP Custom Tag