Alguém pode me dar uma dica do que está errado…?
Servlet:
ServletContext context = getServletContext();
HttpSession session = request.getSession();
try {
AvaliacaoService avalSrv = new AvaliacaoService();
session.setAttribute("avalSrv", avalSrv);
response.sendRedirect("index.jsp");
}
catch(Exception e) {
e.printStackTrace();
}
View:
<%AvaliacaoService avalSrv = (AvaliacaoService) session.getAttribute("avalSrv");%>
<%for(int i = 0; i < avalSrv.aval.length; i++) {%>
<tr class="tit1" id="reg" name="reg" onMouseOver="javascript:changeClassOver(this);" onMouseOut="javascript:changeClassOut(this);">
<td width="50%">&nbsp;&nbsp;&nbsp;<%= avalSrv.aval[i].getDescricao()%></td>
<td width="18%" align="center">&nbsp;<%= avalSrv.aval[i].getDataInicio()%></td>
<td width="18%" align="center">&nbsp;<%= avalSrv.aval[i].getDataFim()%></td>
<td width="14%" align="center">&nbsp;<%= avalSrv.aval[i].getStatus()%></td>
</tr>
<%}%>
sendo que avalSrv tem um array público de objetos.
O mesmo modelo funciona quando testo ele em uma classe main(). Mas quando tento fazer na View ele lança a Exception NullPointerException. Alguém consegue identificar algum erro no laço for? Pois é neste ponto que tá o problema…
valeu a força desde já!