struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Graham" <>
Subject RE: Iterate through resultset
Date Thu, 21 Nov 2002 21:07:25 GMT
You got it exactly right Wendy :-).  Your jsp should never see a ResultSet 
object.  The pattern Wendy is using is very common and considered a best 
practice.  A ResultSet object maintains a database connection throughout its 
life so you should only hold onto it long enough to populate a collection 
with beans.

You'll probably always be using the database but you should still use this 
pattern.  If you don't you'll have massive scalability problems.


>From: Wendy Smoak <>
>Reply-To: "Struts Users Mailing List" <>
>To: 'Struts Users Mailing List' <>
>Subject: RE: Iterate through resultset
>Date: Thu, 21 Nov 2002 13:55:31 -0700
> > I'm working on this application where I get resultsets in jsp pages from
> > business objects.
>I do a similar thing, but I have a DAO layer return a Collection of Value
>Objects.  (How's that for getting a bunch of pattern buzzwords into one
>sentence?)  The VO's are beans, so I can get at the properties with <c:out>
>(or <bean:write> I think was the old way).
>The view never sees anything database specific, it just gets a Collection
>of, say, ResolutionView objects.  (This is a list of possible matching
>records based on a free-form text name the user has entered.  The Action 
>put the Collection into request scope.)
><logic-el:iterate id="resView"
>                 name="foundPersons"
>                 type="edu.asu.vpia.value.ResolutionView"
>                scope="request">
>    <c:out value="${resView.key}"/>
>    <c:out value="${resView.preferredName}" />
>    <c:set var="addressList" value="${resView.preferredAddress}" 
>        <logic-el:iterate id="addressLine" name="addressList">
>          <c:out value="${addressLine}"/>
>        </logic-el:iterate>
>    <c:out value="${resView.statusDesc}" />
>Maybe one day you will move away from a SQL database, and you won't have a
>"ResultSet" anymore.  This way, you only have to make changes to the layer
>of code that provides the Collection and nothing in the view is affected.
>To the JSP, it's all Strings.
>Take all that for what it's worth... I'm _very_ new at this.
>Wendy Smoak
>Applications Systems Analyst, Sr.
>Arizona State University PA Information Resources Management

Help STOP SPAM with the new MSN 8 and get 2 months FREE*

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

View raw message