Question

I have a servlet with:

request.setAttribute("agenzieList",businessLogic.findAllAgenzia());
rd = getServletContext().getRequestDispatcher("/prenotazioneAg.jsp");
rd.forward(request, response);

And in my jsp I want to use my list with the select option. I'm new with JSTL and I tried so:

<select name="agenzia" onChange="toggleSubmit('d',this)">
 <c:forEach items="${agenzieList}" var="agenzia">
  <option value="${agenzia.idAgenzia}">${agenzia.nome}</option>
 </c:forEach>
</select>`

If I write only ${agenzieList} in my jsp I can see my full list with every element. But my selection box remains empty. So the problem I think is in the foreach syntax. Where is my error? I don't understand.

Was it helpful?

Solution

Import the necessary jstl tags,

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

Also make sure you that you your application supports Expression Language.

For info about EL See here

Hope this helps !!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top