wood burning stoves 2.0*
The moose likes Servlets and the fly likes Custom tags - problem getting started Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Custom tags - problem getting started" Watch "Custom tags - problem getting started" New topic
Author

Custom tags - problem getting started

Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi,
I'm having difficulty getting my first custom tag to work. I've taken stuff from a tutorial and as far as I can see everything is in place. Here's the setup:
Included in /WEB-INF/web.xml file:

The contents of /WEB-INF/taglib.tld file:

The Tag Handler class code placed in the /WEB-INF/classes/myTags/ directory

This is the exception I'm getting:

Can anyone tell me what I'm missing? There seems to be something wrong with the .tld file.
Thanks,
Terry


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Hi Terry,
How are you using your taglib and tag on the page?
Cheers
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi Simon,
This is the entire jsp page - very short just to test out the tag. It should just print out the test "Hello from a tag!"

Thanks,
Terry
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Yep ... that's fairly simple. Just checking!
You are right about the problem being in the TLD, the doc type is incorrect and should be ...
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
Try this and let us know if you have any other problems.
Cheers
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi again Simon,
That change in doc type got me past those errors and on to other newer - less serious I think - ones.
I was getting this error first:
java.lang.NoClassDefFoundError: myTags/HelloWorld (wrong name: HelloWorld)
and I supposed it might be Windows path-interpretation so I changed the name of the package directory to Mytags - capital at beginning only
Now I'm getting this one:
org.apache.jasper.compiler.CompileException: /jsp/tagTest.jsp(8,0) No se puede cargar la clase Mytags.HelloWorld
(It's in Spanish 'cos I live in Spain - the message says "cannot load the Mytags.HelloWorld class")
Ideas?
Thanks, you're being of great assistance.
Terry
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Wow ... I've never seen an error message in Spanish before!
I copied your source code and TLD out of this thread and into my Tomcat installation. It all worked first time - apart from the TLD doc type of course!
You're probably correct about Windows ... make sure that your directory is called myTags, and the HelloWorld class has been compiled into this directory, as usual.
Apart from that it should work.
Cheers
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
[This message has been edited by Simon Brown (edited October 29, 2001).]
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi Simon,
I don't know how it happened but the taglib declaration in my jsp dropped the 's' fron the uri ( it had 'mytag' instead of 'mytags' )
All is working now.
Thanks very much,
Terry
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi Simon,
I don't know how it happened but the taglib declaration in my jsp dropped the 's' fron the uri ( it had 'mytag' instead of 'mytags' )
All is working now.
Thanks very much,
Terry
Strange. I got a "message empty" warning from the server and so I reposted.
[This message has been edited by Terence Doyle (edited October 29, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom tags - problem getting started