• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Unable to access ArrayList values from JSP

Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

My problem is like this...........
I have a bean class which returns a ArrayList( infact, i tried Vector as well) object with a set of values...when i try to retrieve these values in a JSP page.....it is not returning the values......the size indicates 0.
When i add a main method to the bean and retrieve the values....it is displaying all the values....when i add a String value to the arraylist
and access it in JSP, it is displaying the value. So, My assumption is
somewhere im doing a mistake in accessing the object from JSP......
pls help me........the corresponding code is as follows::
Bean class:
package biz.vital.products.timesheet.bean;
import java.sql.*;
import java.util.ArrayList;
public class ApproverUserViewFormList

//Vector usernames =null;
public ArrayList usernames =null;

public ArrayList getNames()

Connection con=null;
ResultSet rs=null;
Statement stmt=null;
String query = "select empId from employee";
//usernames =new ArrayList();
usernames=new ArrayList();

try {
}catch (ClassNotFoundException e) {
System.out.println("Exception in Driver::" + e);

try {

stmt = con.createStatement();

while (rs.next())

String temp=rs.getString(1);

} //end of while

} catch(SQLException e){
System.out.println("Exception in sql::" + e);
} finally {
}catch(Exception e) {
}// end of finally...

return usernames;

} // end of get method...

/*public void setNames(Vector usernames1)


public static void main(String ar[])
ApproverUserViewFormList auv = new ApproverUserViewFormList();
System.out.println("main size " +auv.getNames().size());


JSP code

<jsp:useBean id="list" scope="session" class="biz.vital.products.timesheet.bean.ApproverUserViewFormList"/>
<% Vector v1=list.getNames();
out.println("Vector v1 size :" + v1.size());
Vijay Vaddem
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really wonder whats happening.....
i executed the same code without any change on another system and it worked
fine..........what could be the problem with my system???
    Bookmark Topic Watch Topic
  • New Topic