Pass a List to another jsp file
java, jsp
Solution
Agree with ChssPly76 that its probably a sign of trouble if the List is being generated in the JSP, but another alternate approach to get the object to the other JSP is to add it to the HttpServletRequest objects attribute field using a scriplet:
JSP with the List:
<%
request.setAttribute("theList", ListObject);
%>
The other JSP:
<%
List myList = (List) request.getAttribute("theList");
%>
Problem
I wanted to pass a List type object which is in the main JPS to an include JSP ( jsp:include). Since the parm only support strings, I cannot use the parm tag to pass List type data to the include file. Uses examples: ``` <jsp:include page="/jsp/appList.jsp"> <jsp:param name="applications" value="${applications}"/> </jsp:include> ``` Or: ``` <jsp:include page="/jsp/appList.jsp"> <jsp:param name="applications" value="${confirmed_applications}"/> </jsp:include> <jsp:include page="/jsp/appList.jsp"> <jsp:param name="applications" value="${unconfirmed_applications}"/> </jsp:include> <jsp:include page="/jsp/appList.jsp"> <jsp:param name="applications" value="${canceled_applications}"/> </jsp:include> ``` I could create a Simple Tag Handler but I would like to know if there is an easier way.