-----Original Message-----
From: Hu, Jeffery X (Jeff) [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 19, 1999 10:40 PM
To: Subject: Passing a ResultSet from Servlet to JSP
JAVA Gurus,
Can some one help me ?
I am using JSWDK-1.0 (downloaded from Sun Website) to play with JSP and
Servlet. I generated a ResultSet (rs) in a servlet and I would like to pass
this resultset rs to a JSP. The code I wrote as:
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
...
Class.forName(strDrivername);
Connection conn = DriverManager.getConnection(strUrl,
strUserid, strPassword );
Statement strStatement;
strStatement = conn.createStatement();
strSql = "select * from " +
request.getParameter("TableName");
rs = strStatement.executeQuery(strSql);
/*
out.println("Successfully generated ResultSet! <BR>");
while (rs.next())
{
out.println(rs.getString(1));
}
*/
// The following lines can not be compiled
// compiler said method not found
request.setAttribute("rs", rs);
RequestDispatcher rd =
getServletContext().getRequestDispatcher("../jsp/format_RS.jsp");
rd.forward(request, response);
many thanks in advance
Jeff
I am not sure but
I would first all pass contens of rs to some vector
and after pass the vector to request.
while (rs.next())
{
// <file://out.println>
out.println(rs.getString(1));
vec.addItem(rs.getString(1));
}
*/
// The following lines can not be compiled
// compiler said method not found
request.setAttribute("vc", vc);
===========================================================================
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