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

[558 byte] By [Nagireddy_javaDevelopera] at [2007-10-2 15:37:25]
# 1

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?

gimbal2a at 2007-7-13 15:16:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

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 :)

subhash00csa at 2007-7-13 15:16:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

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

}

Nagireddy_javaDevelopera at 2007-7-13 15:16:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
yep.I am trying to get the data to arraylist.its not working my codecan any one give small code snippent for setting the arraylist and that arraylist and assign to resultset here and work successfully...
Nagireddy_javaDevelopera at 2007-7-13 15:16:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
In JSP you write in the following wayArrayList var=(ArrayList)request.getAttribute("Resultset");<td><th><%=var.get(1)%>
Innovaa at 2007-7-13 15:16:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...