No, because I am not re-connecting to the database.  I do not perform
my processing in my JSP's.  Now, let me ask you this.  When you close
your connection in the servlet don't you loose the result set?
Additionally, I do not use (regular) beans to get my connections I use
Weblogic's Connection pooling features then perform JNDI lookup.  This
way my code is completely portable.  See the following code snippet:

public Connection getConnection ( ) {
     try{
     Context context = new InitialContext ( );
     javax.sql.DataSource ds = ( javax.sql.DataSource ) context.lookup
( "DbDataSource" );
          conn = ds.getConnection ( );
          }catch ( NamingException n){
          n.printStackTrace( );
          }catch ( SQLException s){
          s.printStackTrace( );
          }catch ( Exception ex ){
          ex.printStackTrace( );
         }
     return conn;
}

Final though do we see too much processing in JSP's.



----- Original Message -----
From: marco <[EMAIL PROTECTED]>
Date: Thursday, October 19, 2000 3:00 pm
Subject: TO T A Flores

> Hi all,
> The use of all this vector and hashtable is not memory killer in JSP
> processing???
> Is't better to use directly the resultset in the JSP Page????
> like:
> ......
> rs = stmt.excuteQuery(strSql);
> while(rs.next()){
> %>
> <tr>
>    <td><%= rs.getInt("ID") %></td>
> </tr>
> <%
> }
> .......
>
> what of this method is better???
> Why you use a servlet and not a JavaBean to get the ResultSet????
> I use a JavaBean that connect to DB using connectDB() method,
> extract the
> ResultSet using getRs() method and disconnect DB using
> disconnectDB()...i write this simple Bean 'cause i think is better
> to use it... but know i'm
> not sure... can you explain why you use this method to access DB???
>
> Thanx, mark
>
>
>
>
> > I think if you were more specific about your exact problem you might
> > get a little more assistance.  At any rate, below are a couple
> of code
> > snipets.  I use a servlet to perform the query and pass the
> result set
> > to a JSP.  I think the following will at least give you a very good
> > start.
> >
> > 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 vec = new Vector();
> >
> >      try{
> >          ht =(Hashtable) session.getAttribute("Hashtable
> > Name");
> >          enum = ht.keys();
> >          int i=0;
> >          }catch(Exception e){System.out.println(e.toString());}
> > %>
> > <%
> >            while(enum.hasMoreElements()){
> >                vec = (Vector) ht.get(enum.nextElement());
> > %>
> > <table>
> > <tr>
> >     <td><%=vec.get(0).toString()%></td>
> >     <td><%=vec.get(1).toString()%></td>
> >     <td><%=vec.get(2).toString()%></td>
> > </tr>
> > <%
> >      }
> > %>
> >
>
>
========================================================================
===
> 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