Last active
March 3, 2021 18:59
-
-
Save jeffersonchaves/542c84bb6a74280fdf3e237b3eedf5ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.biblioteca; | |
import java.io.IOException; | |
import java.util.List; | |
import javax.servlet.RequestDispatcher; | |
import javax.servlet.ServletException; | |
import javax.servlet.annotation.WebServlet; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
@WebServlet(urlPatterns={"/ListaLivros"}) | |
public class ListaLivros extends HttpServlet { | |
private static final long serialVersionUID = 1L; | |
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | |
RequestDispatcher rd = req.getRequestDispatcher("/listarLivros.jsp"); | |
req.getAttribute("lista"); | |
rd.forward(req, resp); | |
} | |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | |
//ACRESCENTADO | |
Banco banco = new Banco(); | |
List<Livro> lista = banco.getLivros(); | |
req.setAttribute("lista", lista); | |
//ACRESCENTADO | |
RequestDispatcher rd = req.getRequestDispatcher("/listarLivros.jsp"); | |
rd.forward(req, resp); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment