-----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 guru

but I would in first to pass  rs to some Vector and afterword to pass to
request

something like

while (rs.next())               {
                        out.println(rs.getString(1));
                  }

===========================================================================
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

Reply via email to