I'm trying to set a Array list of String to an attribute of session in servlet, and try to access this Array list of Attributes in jsp. But just one value(last value) access in jsp. i want to access All list of attribute.
i searched too much here and there but i don't found about my question.
form jsp:
<form action="/CompleteServlet" method="get">
<%String completeTasks=((ArrayList<String>)session.getAttribute("todoList")).get(i);%>
<input type="hidden" name="completeTasks" value="<%=completeTasks%>" />
<input type="submit" value="Completed">
</form>
from CompleteServlet :
String v=req.getParameter("completeTasks");
HttpSession session=req.getSession();
ArrayList<String> arrOfCompleteTask = new ArrayList<>();
arrOfCompleteTask.add(v);
session.setAttribute("completeTasks", arrOfCompleteTask);
req.getRequestDispatcher("/complete.jsp").forward(req,resp);
form complete.jsp
<%
int size=((List<String>)session.getAttribute("tryCom")).size();
for(int i=0;i<size;i++)
{%>
<%=((List<String>)session.getAttribute("tryCom")).get(i)%>``
<%}%>