Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom tags - problem getting started

 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic