I'm trying to send a list as parameter to a JSP file where i want it showed. My JSP file is called showList.jsp.
Have created a servlet which i use to control everything in my program. When a user click on a button "show List" some code will be performed, and this code will print out the list:
my code:
if (session.getAttribute("show") == "show") {
List opr = null;
try {
opr = func.showlist(opr);
for(int i = 0; i < opr.size(); i++){
System.out.println(opr.get(i));
}
} catch (Exception e) {
System.out.print("Error found, when trying to show list");
}
session.removeAttribute("administrator");
session.removeAttribute("show");
session.removeAttribute("create");
return;
}
Here you can see it just prints what's in my arraylist (size).
Updated code:
List opr = null;
try {
opr = func.showlist(opr);
for(int i = 0; i < opr.size(); i++){
System.out.println(opr.get(i));
}
request.setAttribute("list", opr);
} catch (Exception e) {
System.out.print("Error found, when trying to show list");
}
session.removeAttribute("administrator");
session.removeAttribute("show");
getServletConfig().getServletContext().getRequestDispatcher("/getList.jsp");
}