Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

custum tag

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Author
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dominic Paquette
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the explanation
Dominic
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sam Dalton
Author
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic