0

i am writing 2 jsp files(file1.jsp,file2.jsp). In file1.jsp i am retrieving some names from database and storing them in an ArrayList names 'names'. Now i want to pass that ArrayList to file2.jsp.

/*file1.jsp*/
            //some jsp code 
List names = new ArrayList();
names.add(namesFromDatabase);   //assume 5 names are added.

/*file2.jsp*/
            //here i want print size of ArrayList 'names'
names.size();
            //also i want to print 3rd name from the list.
names.get(2);

Can anyone help me in finding solution for my problem. regards.

2 Answers2

0

Just make the names variable session scoped. Here are the docs

P Varga
  • 19,174
  • 12
  • 70
  • 108
0

Make your second jsp file a tagfile. Tagfiles can accept parameters, so it works similar to a function call.

Kevin
  • 24,871
  • 19
  • 102
  • 158