A Set of SQL Tags
The following is a possible set of SQL tags. Note that this specific syntax is only used for
pedagogical reasons, no endorsement is implied.
Connection, UserId, and Password
The connection tag creates a connection using some userid and password information. To
show tag communication, userid and password are actually subelements of connection.
In this example the con01 object is available after the element.
This example uses the run time stack so userid and password can locate their enclosing
connection tag and can update userid and password data in there. This example also uses
PageContext to register the SQL connection object with the pagecontext using "con01" so it can
be retrieed later.
Tag Library Descriptor
Indicates the names of the tags and their attributes. It associates Tag handlers
with the tags. It also associates the ConnectionExtraInfo as the TagExtraInfo
UserIdTag needs access to its body; this it can do by defining a doAfterBody()
method. This method will take the BodyContent and convert it into a String.
Then it will use the findAncestorWithClass() static method on Tag to locate the
enclosing connection tag instance and will set the desired userid information on
This Tag handler is equivalent to UserIdTag.
This Tag handler provides methods to setUserId() and to setPassword() that
will be used by the enclosed actions; it also provides a getConnection() method
that on demand computes the desired SQL connection. This tag handler needs
not be concerned with the body computation, but it will need to register the
SQL connection object with the pageContext object if an ID is provided.
This class is identical to BarExtraInfo from a previous example.