Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
We want to use our own tag library, so we use a taglib directive,...
where the URI points to a .tld file, containing a Tag Library Description.
The prefix guarantees unique naming when using several libs at the same time.
So this is the tag we use in our .jsp .
We find its name inside the .tld file ( an XML file ),
in the tag's description.
We also find a reference to the associated handler class,
that extends the TagSupport class .
The doStartTag and doEndTag methods are called at the right moments by the JSP engine, and they're required to have the additional specification 'throws JspException'.
We use the pageContext object, present by default, to get a JspWriter and a ServletRequest reference.
By returning this constant from the doStartTag method, we tell the engine to handle the body of this tag.
We could also return SKIP_BODY, with obvious implications.
After handling the tag's body , the doEndTag method is called,...
that we leave by returning this constant, telling the engine to continue handling the rest of the .jsp .
We could return SKIP_PAGE, alternatively.
A taglib that has been tested and approved, can be deployed in a jar-file, where the .tld can be added in a META-INF directory, ...
as long as you specify an identier, ...
that can then be used here instead in jsp's.
The .tld file is an XML file .
Its 'syntax' or rather, Document Type Definition is to be found here.
You can point your browser to the URL (link below), to learn what is required and allowed in a .tld . Contains elucidating comments.