Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problem while retrieving data in the jsp from arraylist

563611Jul 23 2008 — edited Jul 23 2008
Hi friends
iam developing a webapplication using servlet and jsp.

in the servlet iam getting the resultset and that is passing to the jsp
using setattribute but in the jsp it is displaying the first row, some elements of the first row is empty ,so it is stopping there not displaying other records here is the code

servlet
--------

ArrayList al = new ArrayList();
while (resultSet.next() )
{

ArrayList record = new ArrayList();

for (int i=1; i<=7; i++)
{
String value = resultSet.getString(i);
if(!value.equals("") || value!=null || value.trim().length()>0)
{
record.add(value);
}
}
al.add(record);
}

request.setAttribute(SEARCH_RESULT,al);


jsp
------

in the jsp iam getting the values using this

<%
ArrayList list = (ArrayList)request.getAttribute("result");
Iterator iter = list.iterator();
while (iter.hasNext()) {

Object elem = iter.next();

%>
<tr>
<LI> <%=elem %> </LI>
</tr>
<%

}
%>

in the jsp iam getting values like this
[01, T, test , 00275,

this is the first record, it is not displaying the rest of the record. but the size of the list is 100.
i think the probelm is null or empty value, can any one suggest me how to do this in better way.

thanks

Edited by: vinukarun on Jul 23, 2008 6:14 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 20 2008
Added on Jul 23 2008
5 comments
1,693 views