tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kralidis,Tom [Burlington]" <>
Subject SQL insert problem
Date Fri, 01 Apr 2005 19:07:10 GMT


I have a JSTL bit of code which parses an XML document and inserts
selected element values into a PostgresSQL DB.  I use a forEach to loop
through a bunch of elements.  Within the forEach I run an
sql:transaction to insert the records.

The problem, on the inserts, is that the values getting put into the DB
are always from the first iteration of the loop.  When printing them out
in the loop via x:out I get back the correct data, but always the same
values on the inserts.

Code e.g. below (FC2, Tomcat 5.0.25).

Any idea what's going on?  Suggestions valued.



<%@page contentType="text/html"%>
<%@ taglib prefix="c"  uri="" %>
<%@ taglib prefix="x"  uri="" %>
<%@ taglib prefix="sql"  uri="" %>

<sql:setDataSource var="ds" scope="application"
driver="org.postgresql.Driver" url="jdbc:postgresql:mydb" user="u"

<c:set var="requestURL" scope="page" value="http://[host]/somedoc.xml"/>

<c:import url="${requestURL}" varReader="xmlSource">
 <x:parse var="doc" xml="${xmlSource}" scope="page" />

<x:forEach select="//Layer" var="$layer">
 <p>Title: <x:out select="$layer/Title"/></p>
 <sql:transaction dataSource="${ds}">
  <sql:update var="ud">
   insert into service_resources (title) values ('<x:out
 <p>Inserting layer into database END</p>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message