Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TagHandler

 
Akhil Maharaj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am using Tomcat 6.0.14 . I noticed that unless I put my TagHandler class in a package , my JSP is not working . What ever examples I found in HFSJ and other material on the net , always taghandlers are in a package .

Is there any rule that Taghandlers need to be packaged ?

In both cases , TagHandler class is being proeprly placed by eclipse.
In case of packaged version it is
web-inf/classes/com/tags/CustomTags1.class and in case of default package it is at web-inf/classes/CustomTags1.class



Here is the working version , I am attaching TagHandler, TLD and JSP



Here is the NON-WORKING version of the same in a default package .
I am attaching Taghandler , TLD , JSP again




Please let me know - What I am missing .

Thanks
Akhil
[ December 14, 2007: Message edited by: Akhil Maharaj ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any rule that Taghandlers need to be packaged ?

Yes. From JSP2.0, everything must be in packages. Leaving your classes in the default package might work on some containers, but you really should avoid it.

JSP.11.2 JSP Page Implementation Class
As of JSP 2.0, it is illegal to refer to any classes from the unnamed (a.k.a.default) package. This may result in a translation error on some containers, specifically those that run in a JDK 1.4 or greater environment. It is unfortunate,but unavoidable, that this will break compatibility with some older JSP applications. However, as of JDK 1.4, importing classes from the unnamed package is not valid (see http://java.sun.com/j2se/1.4/compatibility.html#source for details). Therefore, for forwards compatibility, applications must not rely on the unnamed package.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic