How to set the ResultSet to the request object
Hi ,
I want to set the ResultSet object to the Request object.
my code....
pStmt=con.prepareStatement("select asc_code from asc_master where rownum between ? and ? order by asc_code asc");
pStmt.setInt(1, i);
pStmt.setInt(2, j);
s=pStmt.executeQuery();
ResultSet resultSet=pStmt.executeQuery();
req.setAttribute("myresultSet",resultSet");
....
now,
I am trying to retrieve the resultset data in jsp.
its not working.
any one help on this
Thank you,
D.Nagireddy
Are you aware that the line
req.setAttribute("myresultSet",resultSet");
will not compile?
Where are you calling this code? In a servlet? If so, are you forwarding or redirecting to the JSP?
What code are you using in your JSP to retrieve the resultset?
Usually its not a good idea to set resultset in request or session.
Becos the resultset will not be available if the connection is closed.
I advise you to populate the resultset data immediately into someother datastructure and set that inturn into request.
hope this helps :)
sorry..that is print mistake.
I given that as
req.setAtrribute("myresultSet",resultSet);
I am forwarding the request.
in jsp...
my code is..
rSet=(ResultSet)request.getAttribute("myresultSet");
while(rSet.next())
{
rSet.getString("1");
etc....
}