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

Reply via email to