XSQL taglib ver. 1.6

    Custom JSP tags. Lets you connect through JDBC to any database, perform some SQL select operator and present output in XML format. So the idea is to use XSLT stuff for publishing data from your database (datasource). For example:

<%@ taglib uri="taglib.tld" prefix="get" %>

<get:XSQL driver="your_jdbc_driver" url="your_db_url" user="scott" password="tiger">
  <get:setQuery>select A,B from Table</get:setQuery>

Tag executes the given query and outputs (inserts into page) result in XML format. And now you may use for example XSL taglib for an appropriate transformation:

<%@ taglib uri="taglib.tld" prefix="get" %>
<%@ taglib uri="taglib1.tld" prefix="xslt" %>

<xslt:applyXSL xslData="sheet.xsl">

  <get:XSQL jndiname="your_datasource">
    <get:setQuery>select C,D from T where C>?</get:setQuery>
    <get:setParameter position="1" type="int">2</get:setParameter>


XML data will be presented as a collection of rows where the each row is a set of attributes:


so for the above mentioned example (select A,B from Table) it will be some like this:


and you may use stylesheet like this for presenting data in HTML table for example:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="rows">
<table border="1" width="100%">
<xsl:for-each select="row">
<td><xsl:value-of select="A"/></td>
<td><xsl:value-of select="B"/></td>

Any null value will be presented as an empty string.

See also XBean taglib for getting XML right from your DAO.

Tags are:


Body tag presents data from your SQL datastore in XML format. Parameters are:

1) driver JDBC driver
2) url database url
3) jndiname JNDI name for datasource (you must set this parameter or <driver,url> pair)
4) user Optional parameter: user name for database connection
5) password Optional parameter: password for database connection
6) xsl Optional parameter: describes an URL for XSL stylesheet (if you will use client side XSL formatting)
7) escape Optional parameter. Possible values are true or false. If this value is true than tag will escape the special symbols (like <, &). Default value is false.


Tag's body defines a SQL select operator. As for JDBC you may use ? sign as a mark for parameters. You can set actual values for parameters through setParameter tag.


Tag's body defines one parameter for SQL statement. Parameters are:

1) position Optional parameter. Describes an index (the first parameter is 1, the second is 2 etc.) Default value is 1.
2) type Optional parameter. Describes a type for this parameter. Possible values are: boolean, byte, date, double, float, int, long, null, string, time, timestamp. Default value is string.
3) type Optional attribute. Describes a boolean value tag's behavior depends on. Default value is true (set parameter).

for downloading:

Library: xsqltag.jar    Description: taglib.tld

 © Coldbeans      Comments?

 See also Coldtags suite - the largest collection of custom JSP tags.

Also in Coldtags: