i use a 2-dimensional array.
i have a bean to which i send the query,
the query is processed by the bean, stored in an 2-d array, and the
array is stored as an object in a hashtable which is returned to the
calling jsp/servlet where i iterate thru the 2-d array and get the
results.
its working pretty ok but u have tro b careful about null pointer
exceptions.
anyone with any suggestions on this?

*****************************************
Amit Wadhwa
Technical Support Representative,
Dell International Services,
Bangalore
*****************************************




-----Original Message-----
From: Hans Bergsten [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 10:47 AM
To: [EMAIL PROTECTED]
Subject: Re: Use of Vectors in JSP


Deepak wrote:
> Hi all
>
> Would you recommend the use of Vectors in jsp pages to hold the query
results
> from a database?
>
> Is it ok then performance wise to iterate over the vector and display
the
> items in the jsp page?
>
> For example, a method in a javabean executes a jdbc statement  that
returns
> some recordsets. These recordsets are added to a Vector and the Vector
is
> returned by the method.
>
> In my jsp page I get the Vector with recordsets from the bean method.
> Then I iterate over the Vector to display its items in a html table.
>
> Is this a good way of doing things?
> If not can anyone suggest a better way?

The methods in Vector are synchronized, so a List or an array is a
slightly more efficient approach. But I would suggest that you look at
JSTL instead. It's <sql:query> action exposes the query result as a
type called a Result. From a Result, you can get an array of arrays
where the first dimension represents rows and the second the column
value, or as an array of Maps where each Map represents a row, with
keys matching column names. Even if you access the database in servlet
code (for instance), you can use utility methods to convert a JDBC
ResultSet to a JSTL Result.

For more info, see:

   <http://java.sun.com/products/jsp/jstl/>

Hans
--
Hans Bergsten                                <[EMAIL PROTECTED]>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <http://TheJSPBook.com/>

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

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

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

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to