Salve a tutti, ho un problema con la gestione delle informazioni dalla action alle jsp. Praticamente devo effettuare una ricerca su database, quindi faccio una form nella pagina jsp con il metodo "searchAnagrafica.do" . Il codice della pagina .jsp è:
Mentre il codice della action searchAnagrafica.do è:codice:<%@ page import="java.util.*, Portal.Anagrafica" %> <% %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Stm Portal- Search</title> </head> <body> <table width=100% height=100% border=3 cellpadding=2 cellspacing=0 summary=""> <tr> <td colspan="2" width=65% height=16%> <h1>Home page di STMPortal:</h1> <h2>La Data e l'Ora di oggi è: <%= new java.util.Date() %></h2></td> <td><%@ include file="testa.jsp" %></td> </tr> <tr> <td width=15%><%@ include file="navigatore.jsp" %></td> <td colspan="2" width=85%><center><h1> Anagrafica Nuova Persona</h1></center> <form action="searchAnagrafica.do" method="POST"> <div align="center"> <h2> Cognome <input type="text" name="cognome" > Nome <input type="text" name="nome" ></h2> </div> <div align="center"> <h2>Matricola<input type="text" name="matricola" > Qualifica <input type="text" name="qualifica" ></h2> </div> <div align="center"> <input type="submit" value="Cerca" /> <input type="reset" value="Annulla" /> </div> <% if(listaAnagrafica!=null){ %> <table> <tr> <th>Cognome</th> <th>Nome</th> <th>Matricola</th> <th>Telefono</th> <th>Qualifica</th> <th>Vedi</th> <th>Elimina</th> </tr> <% for (Anagrafica a : listaAnagrafica) { %> <tr> <th><%= a.getCognome()%></th> <th><%= a.getNome()%></th> <th><%= a.getMatricola()%></th> <th><%= a.getTelefonoLavoro()%></th> <th><%=a.getIdQualifica().getDescrizione()%></th> <th>Vedi</th> </tr> <%}%> </table> <%} %> </form> </td> </tr> </table> </body> </html>
Il problema è che non riesco a gestire nella pagina jsp l'informazione registrata in listaAnagrafica....secondo voi dov'è la mia limitazione?codice:public class AzioneSearchAnagrafica extends Azione{ public String esegui(HttpServletRequest request) throws ServletException { // Creo gli oggetti e li imposto secondo i parametri ricevuti Anagrafica anagrafica = new Anagrafica(); anagrafica.setNome(request.getParameter("nome")); anagrafica.setCognome(request.getParameter("cognome")); anagrafica.setMatricola(request.getParameter("matricola")); Qualifica qualifica=new Qualifica(); qualifica.setDescrizione(request.getParameter("descrizione")); anagrafica.setIdQualifica(qualifica); // uso la facade per interrogare il DataBase try { AnagraficaFacade facade = new AnagraficaFacade(); List<Anagrafica> listaAnagrafica=facade.esisteDipendente(anagrafica.getNome(), anagrafica.getCognome(),anagrafica.getIdQualifica(), anagrafica.getMatricola()); request.getSession().setAttribute("listaAnagrafica", listaAnagrafica); } catch (ModelException ex) { return "errore"; } return "searchOK"; } }
si accettano aiuti....grazie infinite
klaudio

Rispondi quotando