• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trying Head First Servlet and JSP chap 10 Example for Custom tags

 
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simple tag handeler code


JSP Page


and the error i am getting is ---



I am New o Please HELP

Thanks In advance
 
Rohit Gaikwad
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Updates

I thought that myTag.tld file is not getting detected or the tag in not getting detected so Declared
taglib under web.xml file
But still getting the same error

So still waiting for reply from Experts
Thanks
 
Bartender
Posts: 1845
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rohit.

I think your problem is caused because your SelectTagHandler class is not in a package.
Try putting the class in a package (don't forget to update the reference from the tld) and then try it again.


 
Rohit Gaikwad
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stefan Evans
Solution Worked !!!
But Can you please tell me why it was not working with Default package ?
And should i always built my tags in a package ??
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All classes should be placed in a package. Period.

But this is especially important in a web application where the concept of "current directory" is nebulous at best.
 
Stefan Evans
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The basic reason why is that classes in the "default" package (i.e. no package) are not visible to classes that ARE in a package.
This was a change back in Java 1.4 I think - to close a security loophole.

The Tomcat classes running your tag are in a package. Because your tag wasn't in a package, Tomcat couldn't find it - hence the error message "SelectTagHandler cannot be resolved to a type"
 
You've gotta fight it! Don't give in! Read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic