j2ee: The SimpleTag Interface [10/27] Previous pageContentsNext page

doTag() - Called by the container to invoke this tag, and is called once and only once. The lifecycle for SimpleTag is simpler than Tag, IterationTag, or BodyTag.

Lifecycle:

  1. A new tag handler instance is created each time by the container by calling the provided zero-args constructor. Unlike classic tag handlers, simple tag handlers are never cached and reused by the JSP container. This can be a performance issue, but in modern JVMs is not nearly as much of an issue.
  2. The setJspContext() and setParent() methods are called by the container. The setParent() method is only called if the element is nested within another tag invocation.
  3. The setters for each attribute defined for this tag are called by the container. Use JavaBean conventions for this functionality.
  4. If a body exists, the setJspBody() method is called by the container to set the body of this tag, as a JspFragment. If the action element is empty in the page, this method is not called at all.
  5. The doTag() method is called by the container. All tag logic, iteration, body evaluations, etc. occur in this method.
  6. The doTag() method returns and all variables are synchronized.

If you need to create a SimpleTag, but use it as a classic tag, you can use a TagApapter to wrap the SimpleTag and then the SimpleTag can be used where a classic Tag is expected.

Previous pageContentsNext page