I am trying to display the objects in an ArrayList defined in my servlet in the jsp file using session.getAttribute() to retrieve the ArrayList.
<%= String name= (String[]) session.getAttribute("studentObject"); %>
This is my current code in the jsp display file and the error says "Syntax error, insert ")" to complete MethodInvocation". The syntax looks okay to me. Any idea what the error is ?
I defined an ArrayList which consists of student objects which I wanna display. This is how I retrieved it:
String student_name = request.getParameter("studentName");
ArrayList<Object[]> studentList = new ArrayList<Object[]>();
if(student_name != null && student_name.length() > 0) {
PreparedStatement preparedStatement = con.prepareStatement("Select * from users where firstname LIKE ? ");
preparedStatement.setString(1, "%" +student_name+ "%");
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
String first_name = resultSet.getString("firstname");
String last_name = resultSet.getString("lastname");
String email = resultSet.getString("email");
Object[] student = {first_name,last_name,email};
studentList.add(student);
//System.out.println("First Name: " + first_name + "," + "Last Name: " + last_name);
}
session.setAttribute("studentObject",studentList);
//System.out.println(Arrays.toString(studentList.get(0)));