wood burning stoves 2.0*
The moose likes JSP and the fly likes Regarding JSP Tag libraries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Regarding JSP Tag libraries" Watch "Regarding JSP Tag libraries" New topic
Author

Regarding JSP Tag libraries

Merlin Thomas
Greenhorn

Joined: Jul 15, 2011
Posts: 6
I had a question regarding the Tag classes that we create for Custom Tags.
why is it manadatory to keep the tag class in a package?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

As of JDK 1.4, classes in a package cannot import classes in the "default" package. Rule of thumb: always use a package for every class. It helps with organization as well.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Merlin Thomas
Greenhorn

Joined: Jul 15, 2011
Posts: 6
ok, but then why Servlet classes are not placed in any package i.e we can place them, but i we can also write servlets
without the use of packages.
So why then is it manadatory for a Java bean class and Tag classes.
Merlin Thomas
Greenhorn

Joined: Jul 15, 2011
Posts: 6
And Thanks for the reply...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Same answer. Also, just because a package-less servlet seems to work, any change in environment could suddenly make it stop working. It's sort of the luck of the draw.

Bottom line: all classes go in a package. All. Every time.

Anything else is irresponsible and a ticking time bomb.
 
Consider Paul's rocket mass heater.
 
subject: Regarding JSP Tag libraries