14.5. Optionally Including the Tag Body
Most tags either never make use of body content or always do so. This section shows you how to use request time information to decide whether or not to include the tag body. Although the body can contain JSP that is interpreted at page translation time, the result of that translation is servlet code that can be invoked or ignored at request time.
The Tag Handler Class
Optionally including the tag body is a trivial exercise: just return EVAL_BODY_INCLUDE or SKIP_BODY depending on the value of some request time expression. The important thing to know is how to discover that request time information, since doStartTag does not have HttpServletRequest and HttpServletResponse arguments as do service, _jspService, ...
Get Core Servlets and JavaServer Pages™ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.