A couple possibilities:
- returning an array of Strings (or Objects with appropriate toString
methods) works well if you know your result sets will be small and that
the creation of a bunch of temporary objects is not a huge deal.
- for larger or unknown-length result sets, you might consider providing
accessor methods so that the .jsp page can simply get the
java.sql.ResultSet, though you will need to wrap things in a try/finally
block inside the .jsp to ensure the underlying Statement is close()'d
before you return.
- As an alternative to providing direct access to the ResultSet, which
can be ugly for .jsp artist-types to program, you could wrap the
ResultSet with a kinder/gentler type of enumerated interface. Same
problem with needing a try/finally block in the .jsp page to close
things up.
-=- D. J.
John Parrish wrote:
> What is the preferred method of generating HTML back to a JSP page from a
> bean? I was thinking about possibly returning a String array containing
> lines to be outputted and having JSP code loop and print. My scenario would
> be a bean that executes an SQL query and generates and HTML table with the
> results. I am very new to JSP so if I need prodding in a different
> direction, by all means prod! :) Regards
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html