• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom tag handlers - classic type  RSS feed

 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is related to the book Head first JSP and Servlets 2nd edition. It would be great if Kathy and Bert could also answer.

The books says that there are two types of custom tag handlers - Simple and classic. Classic tags are rarely used, so I'd like to skip them
for now. I skipped a few pages related to classic and saw some new pages. I am not sure if these new pages are related to classic tags.

Can someone please tell me if the following topics taken from the book are for classic tags or they are completely unrelated ?

IterationTag lets you repeat the body
When you write a tag handler that extends TagSupport, you get all the lifecycle methods from the Tag interface, plus the one method from IterationTag—doAfterBody(). Without doAfterBody(),
you can’t iterate over the body because doStartTag() is too early, and doEndTag() is too late. But with doAfterBody(), your return value tells the Container whether it should repeat the body
again (EVAL_BODY_AGAIN) or call the doEndTag() method (SKIP_BODY).


Default return values from TagSupport
If you don’t override the TagSupport lifecycle methods that return an integer, be aware of the default values the TagSupport method implementations return. The TagSupport class assumes that your tag doesn’t have a body (by returning SKIP_BODY) from doStartTag()), and that if you DO have a body that’s evaluated, you want it evaluated only once (by returning SKIP_BODY from doAfterBody()). It also assumes that you want the rest of the page to evaluate (by returning EVAL-PAGE from doEndtag()).


etc...

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SimpleTag and SimpleTagSupport are used for implementing simple tags. Pretty much any time you see other classes from the javax.servlet.jsp.tagext package being used, you're dealing with classic tags.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!