LynchWu wrote:

> Hi all
>
> Is it possible to retrive rows of data with one tag,
> and then show each column with different tags,
> within one single jsp page?

Yes.

> If yes, how to pass
> the connection information and result set from
> tag to tag, without using any jsp page-wide variables?
>

What's wrong with using page-wide variables?  That's what they are for.

There are a couple of different programming styles you might use.  The first is
real similar to what you described:

    <mytags:select/>        <-- Do the select, store results

    <mytags:loop>            <-- Some sort of "for" loop
        ... do a row ...
    </mytags:loop>

In this scenario, your select tag would store some sort of array or collection in a
page-scoped variable, which would be used inside the "do a row" stuff.  I would
suggest not using the result set itself in this case, because there's no logic to
close the result set when you're done with it.  You could add another custom tag to
close it afterwards, but now you are counting on the page designer to remember to
include that tag every single time.

Another approach is to use nesting with a different tag design:

    <mytags:select>    <-- Open the result set, store in page var
        <mytags:loop>    <-- Some sort of "for" loop
            ... do a row ...
        </mytags:loop>
    <mytags:select>

In this scenario, you could really use the result set.  In the doStartTag() method
of your select tag, you'd store the result set in page scope with NESTED
visibility, and in the doEndTag() method you'd close it.  In between, the result
set can be accessed by the looping tag.

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to