pass ResultSet from servlet to JSP
Posted
by Dave
on Stack Overflow
See other posts from Stack Overflow
or by Dave
Published on 2009-11-12T23:07:49Z
Indexed on
2010/04/19
14:23 UTC
Read the original article
Hit count: 659
Hi I am doing the following in my SampleServlet.java
//Fill resultset from db
.....
try { ArrayList Rows = new ArrayList();
while (resultSet.next()){
ArrayList row = new ArrayList();
for (int i = 1; i <= 7 ; i++){
row.add(resultSet.getString(i));
}
Rows.add(row);
}
request.setAttribute("propertyList", Rows); RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher("/DisplayProperties.jsp"); requestDispatcher.forward(request,response);
#and then in my jsp DisplayPropeties.jsp i have
<%
ArrayList rows = new ArrayList();
if (request.getSession().getAttribute("propertyList") != null) {
rows = (ArrayList ) request.getSession().getAttribute("propertyList");
}
%>
but rows is allways null.
Can anyone help with what I am doing wrong please.
© Stack Overflow or respective owner