Best way to use taglibs,
You can get info abot tags at
http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html
Please study and implement.
We carried out these type of solution using tags.
Jaisinh
-----Original Message-----
From: Daryani Santosh [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 22, 2001 7:12 AM
To: [EMAIL PROTECTED]
Subject: Re: Fetching Data from Bean
This is how I was converting resultset to a vector , in a bean and returning
the
vector back to the JSP page
Following code is from a bean method , create a vector of vectors to hold
the
resultset
Vector rsVector = new Vector() ;
try{
Statement stmt =null;
stmt = con.createStatement();
rs = stmt.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int colCount = rsmd.getColumnCount();
int rowCount = 0;
while ( rs.next() )
{
Vector newRow = new Vector();
rowCount ++;
for (int i = 1 ; i <= colCount; i++ )
{
newRow.addElement(rs.getObject(i));
}
rsVector.addElement(newRow);
}
rs.close();
stmt.close();
}
catch(SQLException se)
{
System.out.println(se);
}
return rsVector;
}
//At the JSP end you can take the size of the vector , that will be number
of
rows , for all those rows
//get values of all columns
hope this helps
Santosh
"Puneet Kathuria, Gurgaon" <[EMAIL PROTECTED]> on 01/21/2001 11:26:31
PM
Please respond to A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Santosh Daryani/IT/Aon Consulting)
Subject: Re: Fetching Data from Bean
Thanks for the suggestion but i don't think this is an adequate way of
writing JSP. For an enterprise wide solution, it's not a proper approach to
write db access mechanism embedded in web pages.
Ok my real question, is how to pass a resultset back to JSP from a bean ? I
don't want to return back the resultset object even as for a thumb rule that
front end should never know about data access.
How can i convert say a resultset to a 2-dimension array or vector of
vectors or any other methodology for tranferring data back to web page.
Is there any sample application available on web that can be used a model
for writing the JSP applications, ie. following n-tier architecture.
Thanks very much
regards
Puneet
> ----------
> From: homai[SMTP:[EMAIL PROTECTED]]
> Reply To: A mailing list about Java Server Pages specification and
> reference
> Sent: Saturday, January 20, 2001 9:56 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Fetching Data from Bean
>
> ----- Original Message -----
> From: "kishore" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, January 19, 2001 8:24 PM
> Subject: Re: Fetching Data from Bean
>
>
> > try this way ...
> >
> > <table>
> > <tr > <!-- // let name and address in tabular form -->
> > <td> name </td>
> > <td> address</td>
> > </tr>
> > <%
> > try {
> > //
> > Connection c =
> DriverManager.getConnection("jdbc:odbc:TABLE","usr","pwd");
> > Statement s = c.createStatement();
> > ResultSet r = s.executeQuery("select name , address from usertable
> where
> > username = '"+loginBean.getUsername()+"'");
> > while( r.next())
> >
> >
> > %>
> > <tr>
> > <td> <%= r.getString("name") %> </td>
> > <td> <%= r.getString("address") %> </td>
> > <tr>
> > <%
> > }
> > r.close();
> > s.close();
> >
> > }catch(SQLException e){
> > System.out.println("SQLException thrown @ xyz.jso");
> > }catch(ClassNotFoundException ee){
> > System.out.println("sun.jdbc.odbc.JdbcOdbcDriver class not
> fount
> > 2 xyz.jsp ");
> > }
> > %>
> > </table>
> > ----- Original Message -----
> > From: Puneet Kathuria, Gurgaon <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, January 19, 2001 9:58 PM
> > Subject: Fetching Data from Bean
> >
> >
> > > Hello All:
> > >
> > > I have a jsp page that displays data in tabular format.
> > > I have written a bean that performs the database queries & creates a
> long
> > > string (html) and it's returned back to display on the page.
> > >
> > > Can i bring the whole resultset in any form to jsp page & then display
> > > (maybe as arrays)
> > >
> > > Any suggestions as to how / in what form to bring data to jsp page
> apart
> > > from the strategy am following ?
> > >
> > > regards
> > >
> > >
> >
> ==========================================================================
> =
> > > 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://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!?
> > Get your free @yahoo.com address at http://mail.yahoo.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://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".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> 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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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