Hi,
I need help in jsp to display values of an ArrayList in jsp.
There is a java file containing a method which is returning an ArrayList.
I want to display the records of the ArrayList in jsp in a tabular form/way.
if (request.getParameter("action") != null) { Open connection to the database; Read parameters from the JSP formular (parameters are NAME and YEAR of each student); stmt.executeUpdate("insert into Students(name,year) values('"+name+"', '"+year+"')"); Close the connection;
ArrayList<Student> students = StudentsManager.getInstance().getStudents(); %> <html> <body bgcolor=#4AA02C> <center> <h2>Student list</h2> <table border="1" cellspacing="1" cellpadding="8" bgcolor= #EBDDE2> <tr> <td bgcolor= #FF9966><b>ID</b></td> <td bgcolor= #FF9966><b>Name</b></td> <td bgcolor= #FF9966><b>Year</b></td> </tr> <% int no = 1; Student s = students.get(no); %> <tr> <td><%= no %></td> <td><%= s.getName();%></td> <td><%= s.getYear();%></td> </tr> <% no++; }
%>