Hi Greg,
Comments below...
On Tue, 15 May 2001, Greg Callaghan wrote:
> Hi,
>
> I am trying to implement in JSP a nested JDBC query, to produce output like
> the following -:
>
> ---------------------------------------------------
> * Result 1 from Query 1
> - Release 1 from Query 2(using Query 1, Result 1 input)
> - Release 2 from Query 2(using Query 1, Result 1 input)
> - Release 3 from Query 2(using Query 1, Result 1 input)
> * Result 2 from Query 1
> - Release 1 from Query 2(using Query 1, Result 2 input)
> - Release 2 from Query 2(using Query 1, Result 2 input)
> - Release 3 from Query 2(using Query 1, Result 2 input)
> * Result 3 from Query 1
> - Release 1 from Query 2(using Query 1, Result 3 input)
> - Release 2 from Query 2(using Query 1, Result 3 input)
> - Release 3 from Query 2(using Query 1, Result 3 input)
> ---------------------------------------------------
>
> I was hoping to use DBTags and have nested <sql:resultSet> (ie 2 levels,
> outer and inner loop) however this does not seem to work, as no output past
> "Result 2" above occurs.
>
> Q1 - Does anyone know whether there is a way to have nested DBTags in JSP
> pages?
I would think that this should work. Could you send a snippet from your
JSP? The way to do it would be to start a new statement inside your
result set. Actually, per the JDBC spec:
Only one ResultSet object per Statement object
can be open at any point in time.
If you put a new statement object inside your result set, it should
work. Let me know if it does/does not!
> Q2 - If the answer is no, what would be the next easiest approach to getting
> the output I want in JSP? I was hoping to do as much as possible in JSP (cf
> scriptlets / beans).....well at least keep HTML output format in JSP (cf
> having "out.println" statements in java code).
>
> Note - I tried using <jsp:include ...> within the main DBTag loop to
> reference a second JSP page with the inner loop in this, however I get an
> error indicating that one can not use <jsp:include ...> within a customer
> tag.
>
Yup, the current JSP spec does not allow includes inside a custom
tag. (Aside: I saw one of the Tomcat developers admit at one point that
this spec limitation arose from a limitation in Tomcat.) In any case,
recent builds of Tomcat support includes inside of custom tags, as does
the new provisional spec.
- Morgan