Reputation: 2467
I am trying to pass String array from one jsp to another. I am using JSTL in my JSP. In my first JSP i am doing like this
<c:if test="${fn:length(empBean.additionalEmailAddr) gt 0}">
<c:forEach begin="0" end="${fn:length(empBean.additionalEmailAddr) - 1}" var="ind" >
<input type="hidden" name="inbdAdditionalEmailAddr" value="${empBean.additionalEmailAddr[ind]}"/>
</c:forEach>
</c:if>
and trying to access the values in another jsp as follows
<%
String[] inbdAddEmlAddr = request.getParameter("inbdAdditionalEmailAddr");
%>
and i am planning to use JSTL to print the array values.
In the second jsp i am getting type mismatch error. Please help.
Is this the right approach ? Any help is appreciated
Thanks
Upvotes: 2
Views: 2447
Reputation: 94499
request.getParameter()
returns a String
which the code attempts to assign to a String[]
, causing the exception.
Use request.getParameterValues('inbdAdditionalEmailAddr');
to retrieve parameters as an array.
See the documentation.
Upvotes: 1