Reputation: 31
I am setting a attribute to the session as:
HttpSession session = request.getSession();
System.out.println(al);
session.setAttribute("arraylist",al);
The al is the list of Employee
object. Also I can see the System.out is printing in the console.
But when I am trying to get the list from jsp as:
<%
List<Employee> employees = (List<Employee>)session.getAttribute( "arraylist" );
for(int i=0;i<employees.size();i++){
Employee emp = employees.get(i);
out.println(emp.getFirstName());
out.println(emp.getLastName());
out.println(emp.getAddress());
out.println(emp.getContact());
out.println(emp.getEmail());
}
%>
I am getting the error:
Attribute value (ArrayList<Employee>)session.getAttribute("arraylist") is quoted with " which must be escaped when used within the value
I am using Tomcat 6.0.33. Any information will be very helpful.
Thanks.
Upvotes: 3
Views: 7315
Reputation: 2388
Maybe
-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false
helps. Check the more strict quoting rules.
Upvotes: 5
Reputation: 94625
Use JSTL forEach
to iterate the collection.
<c:forEach var="emp" items="${arraylist}">
<c:out value="{emp.firstName}"/>
</c:forEach>
Upvotes: 3