I know that it is best to use jstl in JSPS, but I have been explicitly told to use scripts in this project. My question is that my servlet bound the Arraylist element to the request object, and I wanted to loop on that element with a script.
Example: my servlet attaches this and forwards it to jsp
request.setAttribute("list", Content); where Content is Arraylist<String>
jsp should restore this object and print it on the page I tried:
<%
ArrayList<String> cont = (ArrayList)request.getAttribute("Content");
for (int i=0;i<cont.size();i++)
{
out.println(cont.get(i));
}
%>
Here is the error I get
org.apache.jasper.JasperException: An exception occurred processing JSP page /EnrolledSuccess.jsp at line 35
32: ArrayList<String> cont = (ArrayList)request.getAttribute("cont");
33: for (int i=0;i<=cont.size();i++)
34: {
35: out.println(cont.get(i));
36:
37: }
38: %>
source
share