Frage

Using an ArrayList of type Countries that is a bean class I'm getting only a blank page as output when using the following code:

<%
    ArrayList<Countries> countryList = (ArrayList<Countries>) request.getAttribute("al");
%>

<c:forEach items="${countryList}" var="item">
    <c:out value="${item.code}"></c:out>
    <c:out value="${item.name}"></c:out>
</c:forEach>
War es hilfreich?

Lösung

you need not to set in request attribute again.You can use below code

<c:forEach items="${al}" var="item">
    <c:out value="${item.code}"></c:out>
    <c:out value="${item.name}"></c:out>
</c:forEach>

This way you can get rid of scriptlet also.

Hope it Helps

Andere Tipps

The reason is the EL (Expression language) can't find any variable named countryList in any valid scope. The variable declared in the scriptlet is not visible to the EL so you must add it to a valid scope for example the request so:

<%
    ArrayList<Countries> countryList = (ArrayList<Countries>) request.getAttribute("al");
    request.setAttribute("countryList", countryList);
%>

<c:forEach items="${countryList}" var="item">
    <c:out value="${item.code}"></c:out>
    <c:out value="${item.name}"></c:out>
</c:forEach>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top