JDBC JSON JSTL example

put this code in index.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="json" uri="http://www.atg.com/taglibs/json" %>

<sql:query var="rs" dataSource="jdbc/TestDB">
    select prod_code, description from product_code
</sql:query>
{success:true,rows:
<json:array name="rows" prettyPrint="true">
    <c:forEach var="row" items="${rs.rows}">
        <json:object>
            <json:property name="prod_code" value="${row.prod_code}"/>
            <json:property name="description" value="${row.description}"/>
        </json:object>
    </c:forEach>
</json:array>
}