Alguém podia me ajudar a achar a achar o erro ao tentar exibir uma Lista com sessão?
abaixo meu formulário:
<form action="ServletNoticias" method="post">
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>Título</td>
<td><input type="text" name="titulo" /></td>
</tr>
<tr>
<td>Sub tìtulo</td>
<td><input type="text" name="subtitulo" /></td>
</tr>
<tr>
<td>Texto</td>
<td><textarea name:"texto" cols="20" rows="10"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Cadastrar Notícia" /></td>
<input type="hidden" name="operacao" value="cadastraNoticia">
</tr>
</table>
</form>
meu servlet:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String operacao = request.getParameter("operacao");
List<Noticia> noticias = new ArrayList<Noticia>();
String titulo = request.getParameter("titulo");
String subtitulo = request.getParameter("subtitulo");
String texto = request.getParameter("texto");
Noticia noticia = new Noticia(titulo, subtitulo, texto);
HttpSession sessao = request.getSession();
if (operacao.equals("cadastraNoticia")) {
if (sessao.getAttribute("blog") == null) {
Blog b = new Blog();
b.addNoticia(noticia);
sessao.setAttribute("blog", b);
} else {
Blog b = (Blog) sessao.getAttribute("blog");
b.addNoticia(noticia);
}
}
request.getRequestDispatcher("index.jsp").forward(request, response);
}
e meu código para exibir a lista:
<fieldset>
<legend>Notícias</legend>
<c:forEach var="n" items="${blog.noticias }">
${n.texto }
</c:forEach>
</fieldset>
se alguém puder me ajudar agradeço