The moose likes JSP and the fly likes Rule of Thumb: TagLib vs Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Rule of Thumb: TagLib vs Bean" Watch "Rule of Thumb: TagLib vs Bean" New topic
Author

Rule of Thumb: TagLib vs Bean

Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

I had previously asked about when to use scriplets and when to use servlets.
Now I am wondering if there is a rule of thumb as to when it is better to use a Custom Tag over a Bean or vice versa.
Also, does a Tag Library hold it's values for the entire session or is it just for the instance of a particular page that is using the Tag Library? The answer to this question could very well answer my first question I suppose.
Thanks.


My Blog | DZone Articles
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1860
I put a lot of work into this topic for my book and luckily (depending how you see it!), that chapter that talks about all of this is available to download from here.
To summarise - beans for data, tags for actions. Of course, the chapter goes into much more detail than this, explaining the reasoning behind this rule of thumb and taking things like the tag lifecycle and the way that the container uses tags and beans into account.
Hope it's useful!
Simon
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

Thanks for the link Simon.
"...we'll look at the frequently asked question of rather to use JavaBeans or custom tags to encapsulate serverside functionallity...."
PERFECT!!
Just was I was looking for.
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

Simon, the chapter you gave me the link for cleared up just about every concern I had over when to use Tags and when to use JavaBeans. Then at the end, you eluded to some things in Chapter 9 that I am very interested in learning.
So now, off to buy your book!!
Thanks again.
 
IntelliJ Java IDE
 
subject: Rule of Thumb: TagLib vs Bean
 
Threads others viewed
Very Much Confused !!!
Getting SQL Data in JSP or Servlet
Custom Tags v/s Java Beans
Question related to abstract class and Interface
About jsp:useBean tag
developer file tools