BBJSP SQLTags (Deprecated)
The BBJSP system is deprecated. For new development, use BBxServlet.
Description
In BBj 16.0 and higher, the BBJSP SQL library provides a common set of tags
that can be used to access a database within the BBJSP framework.
Creation
Tag libraries need specifically importing into a BBJSP page by using the taglib directive.
Here's an example of how to register this tag library in your page:
<%@ taglib uri='/WEB-CFG/tld/sql.tld' prefix='sql' %>
The uri
points to the tag library definition within the web application and the
prefix
defines how the tag will be prefixed in the markup.
Tags
Example
<!DOCTYPE html/> <%@ taglib uri='/WEB-CFG/tld/core.tld' prefix='c' %> <%@ taglib uri='/WEB-CFG/tld/sql.tld' prefix='sql' %> <!-- Demo of executing an SQL query --> <html> <head> <title>SQL Tags</title> <style> table {border:2px solid black;text-indent: 4px;padding:0px;border-spacing: 0px;} th{border:0px;border-bottom:2px solid black;padding:4px;background-color:ABFBFF;} td{border:0px;padding:1px;background-color:E3FEFF;} .l {border-left:1px solid black;} </style> </head> <body> <sql:query template='tpl' var='result' datasource='ChileCompany' sql='SELECT * FROM SALESREP' />
<table width='100%'> <tr> <th align='left'>Code</th> <th align='left' class='l'>Name</th> <th align='left' class='l' colspan='4'>Address</th> <th align='left' class='l'>Phone</th> </tr> <c:iterate data="${result}" id="item" > <c:template id='theRecord' template='${tpl}' data='${item}' /> <tr> <td>${theRecord['SALESPERSON']}</td> <td class='l'>${theRecord['NAME']}</td> <td class='l'>${theRecord['ADDRESS']} ${theRecord['ADDRESS2']}</td> <td>${theRecord['CITY']}</td> <td>${theRecord['STATE']}</td> <td>${theRecord['ZIP']}</td> <td class='l'>${theRecord['PHONE']}</td> </tr> </c:iterate> </table> <h3>The Query</h3> <ul> <p><code>SELECT * FROM SALESREP</code></p> </ul> <h3>The Template</h3> <ul> <textarea rows="3" cols="100">${tpl}</textarea> </ul> <h3>The RAW data</h3> <ul> <textarea rows="9" cols="100">${result}</textarea> </ul> </body> </html>
|
See Also
BBJSP
BBJSP Tag Libraries