Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di Armun
    Registrato dal
    Jan 2012
    Messaggi
    55

    [Java] visualizzare tutti gli elementi

    Ragazzi ho una servlet su cui memorizzo dal db tutti gli elementi col metodo getAll()

    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    // TODO Auto-generated method stub
    UtenteDao ud=new UtenteDao();
    List<Utente> lista= ud.getAll();
    req.setAttribute("lista", lista);

    req.getRequestDispatcher("tutti.jsp").forward(req, resp);

    }

    per visualizzare tutti gli elementi sulla jsp come posso fare?

    <%@ 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>Insert title here</title>
    </head>
    <body>
    Lista di tutti gli utenti registrati:

    <table border="1">

    <td>

    <%

    ?????????????????

    %>

    </td>



    </table>
    </body>
    </html>


    Non so cosa mettere al posto dei "??????????????????????????" potete aiutarmi?
    se faccio List lista= request.getAttribute("lista") non posso farlo perche non riconosce List nella jsp

  2. #2
    Utente di HTML.it L'avatar di Armun
    Registrato dal
    Jan 2012
    Messaggi
    55
    ho provato cosi ma nn va la jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.util.*" %>
    <!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>Insert title here</title>
    </head>
    <body>
    Lista di tutti gli utenti registrati:

    <table border="1">

    <td>

    <%

    List lista= (List) request.getAttribute("lista");
    for(Object u:lista){
    out.println(u.toString());

    }

    %>

    </td>



    </table>
    </body>
    </html>

  3. #3
    Utente di HTML.it L'avatar di Armun
    Registrato dal
    Jan 2012
    Messaggi
    55
    ok risolto da solo

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.