Duncan,

You're right if the result set object is not passed to a collection it
will be lost when the stmt/connection is closed.  I think enough of
this thread since it was already sufficiently covered.

I have for those who have an inability to search the archive attached
the code in question.

In the servlet . . . .

     rs = stmt.executeQuery( sql );
     while (rs.next( ) ){

     Vector vector = new Vector();
     vector.add(new Integer(rs.getInt("var1")));
     vector.add(new Integer(rs.getInt("var2")));
     vector.add(rs.getString("var3"));
     vector.add(rs.getString("var1"));
     hashtable.put(rs.getString("var1"),vector);

     session.setAttribute("Name the hashtable", hashtable);

then in the JSP . . . .
<%
     Enumeration enum=null;
     Hashtable ht = new Hashtable();
     Vector v = new Vector();

     try{
        ht =(Hashtable) session.getAttribute("HashtableName");
         enum = ht.keys();
         int i=0;
         }catch(Exception e){System.out.println(e.toString());}
%>
<%
           while(enum.hasMoreElements()){
               v = (Vector) ht.get(enum.nextElement());
%>
<table>
<tr>
    <td><%=v.get(0).toString()%></td>
    <td><%=v.get(1).toString()%></td>
    <td><%=v.get(2).toString()%></td>
</tr>
<%
     }
%>



----- Original Message -----
From: Duncan Rose <[EMAIL PROTECTED]>
Date: Saturday, November 4, 2000 6:28 am
Subject: Re: resultset to jsp

> My understanding of it is that if you close the db
> connection or the prepared statement or whatever, the
> result set becomes invalid, so you can't reference
> the ResultSet object after a connection closure (i.e.
> the connection is not held open if you have a resultset
> reference, rather the reference becomes invalid if you
> close the connection).
>
> Could be wrong though.
>
>        -Duncan
>
> -----Original Message-----
> From: Ron Chan [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, November 04, 2000 2:02 PM
> To: [EMAIL PROTECTED]
> Subject: Re: resultset to jsp
>
>
> Hi,
>
> 1. you have a bean that does the database query.
> 2. either that bean or a utility, iterates the
> resultset for the column values, puts them into the
> TableModel. put the TableModel into the session.
> 3. In the jsp file, get from the session, and loop to
> display into <table><tr><td>.
>
> one reason for not using the resultset was my concern
> that the database connection is kept open. Can someone
> confirm whether this is true or not.
>
> thanks,
>
> ron
>
>
>
> --- T A Flores <[EMAIL PROTECTED]> wrote:
> > If you use the <table>or JTable how exactly are you
> > getting the result
> > set from the Servlet/Bean?
> >
> > ----- Original Message -----
> > From: Ron Chan <[EMAIL PROTECTED]>
> > Date: Friday, November 3, 2000 5:02 pm
> > Subject: Re: resultset to jsp
> >
> > > Hi,
> > >
> > > why not put the resultset into a TableModel format
> > for
> > > transport. Whatever display, if AppleJTable, if
> > html, can loop
> > > rows and columns into a
> > > <table> tag. etc.
> > >
> > > ron
> > >
> > >
> > > --- T A Flores <[EMAIL PROTECTED]> wrote:
> > > > It is possible, however, why would you want to
> > use
> > > > and array why not
> > > > use a vector of hashtables.  I posted a response
> > to
> > > > a similiar problem
> > > > using servlet to jsp last month (I believe more
> > > > toward the middle of
> > > > October).  Why don't you search the archive and
> > see
> > > > if that helps you
> > > > at all.
> > > >
> > > > ----- Original Message -----
> > > > From: Ginni <[EMAIL PROTECTED]>
> > > > Date: Monday, January 3, 2000 3:27 pm
> > > > Subject: resultset to jsp
> > > >
> > > > > hi,
> > > > >
> > > > > I query my database and get a resultset in my
> > bean
> > > > , now is it
> > > > > possible to
> > > > > get all the records in the resultset into an
> > > > array. i want to
> > > > > retrieve this
> > > > > array in my jsp and display the values there.
> > is
> > > > that possible
> > > > >
> > > > > there are 2 things here,
> > > > >
> > > > > 1. i need to get the resultset into an array
> > (in
> > > > asp, i use
> > > > > getrows() for
> > > > > this purpose)
> > > > > 2. i need to get the array into my jsp. (could
> > i
> > > > use getProperty
> > > > > for this)
> > > > >
> > > > > thanks for ur time,
> > > > > :-)
> > > > > Have a great Day!
> > > > > -Ginni
> > > > >
> > > > >
> > > >
> > >
> >
>
========================================================================
> > > > ===
> > > > > 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
> > > > >
> > > >
> > > >
> > >
> >
>
========================================================================
> > ===
> > > > 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
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > From homework help to love advice, Yahoo! Experts
> > has your answer.
> > > http://experts.yahoo.com/
> > >
> > >
> >
>
========================================================================
> > ===
> > > 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
> > >
> >
> >
>
========================================================================
===
> > 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
>
>
> __________________________________________________
> Do You Yahoo!?
> Thousands of Stores.  Millions of Products.  All in one Place.
> http://shopping.yahoo.com/
>
>
========================================================================
===
> 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
>
>
========================================================================
===
> 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
>

===========================================================================
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