Generate XML with JSTL and SQL

from http://krook.net/archives/210

<%@ page contentType=“text/xml; charset=UTF-8″ pageEncoding=“UTF-8″ session=“false”%>

<?xml version=“1.0″ encoding=“UTF-8″ ?>

<%@ taglib prefix=“sql” uri=“http://java.sun.com/jsp/jstl/sql” %>
<%@ taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core” %>

<sql:setDataSource dataSource=“jdbc/yourdatasource”/>
<sql:query var=“items”>
  SELECT ID id, TITLE title, ABSTRACT abstract, BODY body, THUMBNAIL thumbnail
    FROM NEWS_ARTICLES NA, NEWS_ARTICLE_IMAGES NAI
    WHERE NA.ID = NAI.NA_ID;
</sql:query>

<results>
 <c:forEach var=“row” items=“${items.rows}” >
  <result id=“<c:out value=”${row.id}“/>“>
    <title><c:out value=”${row.title}“/></title>
    <abstract><c:out value=”${row.abstract}“/></abstract>
    <thumbnail><c:out value=”${row.thumbnail}“/></thumbnail>
    <body><c:out value=”${row.body}“/></body>
  </result>
 </c:forEach>
</results>