aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes custum tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "custum tag" Watch "custum tag" New topic
Author

custum tag

Dominic Paquette
Ranch Hand

Joined: Dec 13, 2002
Posts: 64
Hi
I noticed that, when writing a tag handler class, if I don't specify a package delaration, I get a translation error when trying to access the jsp page where the tag is used. Does anybody know if this is specific to Tomcat?
Thanks in advance
Dominic
Sam Dalton
Author
Ranch Hand

Joined: Jul 26, 2001
Posts: 170
Dominic,
There is a very good reason for this behaviour. When a JSP page is translated into a servlet at run time it is placed in a package (for tomcat this is org.apache.jsp). In order for this servlet to correctly use your tag handler it must import its package, and if the tag handler is not in a package it can't import it.
Hope this helps
Cheers
Sam


<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
Thanks for the explanation
Dominic
Dharmin Desai
Ranch Hand

Joined: Feb 28, 2002
Posts: 81
Dear Sam and Dominic,
I understand the question and now i can also realise that, but Sam i m unable to understand yr answer.
When a JSP page is translated into a servlet at run time it is placed in a package (for tomcat this is org.apache.jsp). In order for this servlet to correctly use your tag handler it must import its package, and if the tag handler is not in a package it can't import it.

Sam, Even When i m declaring a Tag handler class in a package that time also my Tag Handler class is not importing org.apache.jsp package.
Sam, Please elaborate yr answer.
Sincerely yours, Dharmin


SCJP2 (93%),SCWCD(88%)<br />-------------------------------<br />Never under estimate yr self, just represent yr profile in proper manner.
Sam Dalton
Author
Ranch Hand

Joined: Jul 26, 2001
Posts: 170
Dharmin,
If you look at the servlet that is generated from your JSP page (this can be found in the %TOMCAT_HOME%/work directory) you will see that it imports your tag handlers package.
n.b.: this has changed slightly as of Tomcat 5, as there are lots of other complications introduced (you still need to package your tags however!)
Hope this helps.
Sam
[ January 09, 2003: Message edited by: Sam Dalton ]
yi zhu
Ranch Hand

Joined: Sep 10, 2002
Posts: 41
I'm using Tomcat 4.1. The servlet generated from my jsp did not[B] import my tag package. When my tag handler class was used, this servlet used the full qualified class name of my handler class.
However, as mentioned by Sam, this servlet has his own package called [B]org.apache.jsp
. So when your tag handler class has no package declaration, this servlet will look it up in org.apache.jsp and all imported package. This will be obviously fruitless.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: custum tag
 
Similar Threads
release method + Classic Tags
RequestDispatcher repeating /servletname problem
Tags and Tag handlers
function of "em"
onchange and onkeypress event on a select dropdown