wood burning stoves 2.0
The moose likes JSP and the fly likes Custom Tag  NOT Compiling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom Tag  NOT Compiling" Watch "Custom Tag  NOT Compiling" New topic

Custom Tag NOT Compiling

Sanjay Deshpande
Ranch Hand

Joined: May 22, 2001
Posts: 111
I have a tag file :
import java.io.IOException;
import java.util.Date;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
// Hello tag accepting a name attribute.
public class AttribHelloTag extends TagSupport
private String name;
// Property getter for name
public String getName() {
return name;
// Property setter for name
public void setName(String name) {
this.name = name;
public int doEndTag() throws JspTagException {
String dateString = new Date().toString();
try {
pageContext.getOut().write("Hello <b>" + name + "</b>.<br/>");
pageContext.getOut().write("My name is " + getClass().getName() +
" and it's " + dateString + "<p/>");
catch (IOException ex) {
throw new JspTagException("Hello tag could not write to JSP out");
return EVAL_PAGE;
I m getting error:
1.following not found.
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
2. extends TagSupport not found..
Any solution?
How to write a tag? what is needed?
Sam Dalton
Ranch Hand

Joined: Jul 26, 2001
Posts: 170
In order to compile the tag you must have the servlet/jsp apis within your classpath. If you are using Tomcat 4.0 then simply putting
in your class path will do the trick.
Hope this helps

<a href="http://www.samjdalton.com" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of [http://www.amazon.com/exec/obidos/tg/detail/-/1590592255/qid=1068633302//ref=sr_8_xs_ap_i0_xgl14/104-4904002-9274339?v=glance&s=books&n=507846]Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1861007701/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/186100561X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
Dominic Paquette
Ranch Hand

Joined: Dec 13, 2002
Posts: 64
From what I understand, your compiler can't find the javax.servlet.jsp and javax.servlet.tagext packages. In order for your compiler to find these packages, you need to tell him where they are. To do this, you use the classpath for example:
javac -classpath c:\j2sdkee\lib\j2ee.jar AttribHelloTag.java
Hope this helps
Sanjay Deshpande
Ranch Hand

Joined: May 22, 2001
Posts: 111
HI , Thnx for the reply.
i m using tomcat3.3 and have this in class path
however , this is not working for me.
What could be the problem?
Sanjay Deshpande
Ranch Hand

Joined: May 22, 2001
Posts: 111
My tag has comiLped.
i have tld like this :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//
DTD JSP Tag Library 1.1//EN"
<!-- a tag library descriptor -->
<info>A simple tab library for the
<info>Say Hi</info>
%@ taglib uri="/WEB-INF/jsp/mytaglib.tld"
prefix="first" %>
<TITLE>Hello Tag</TITLE>
<BODY bgcolor="#ffffcc">
<B>My first tag prints</B>:
org.apache.jasper.compiler.CompileException: C:\TomCat\jakarta-tomcat-3.3a\webapps\examples\jsp\Hellotag.jsp(0,0) Unable to open taglibrary /WEB-INF/jsp/mytaglib.tld : Parse Error in the tag library descriptor: External entity not found: "http://java.sun.com/j2ee/dtds/
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 364
There doesn't appear to be a problem with deployment descriptor or you tld as the compiler actually finds the tag class. Make sure the package exists in the jar and make sure it is in the classpath.

No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
Something that I have noticed from your TLD file is that you've not specified a package for your tag handler class. For custom tags to work properly, you should place your tag handler class inside a package.
I agree. Here's the link: http://aspose.com/file-tools
subject: Custom Tag NOT Compiling
jQuery in Action, 3rd edition