package cs3220.controller; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import cs3220.model.GuestBookEntry; @WebServlet(urlPatterns = "/GuestBook") public class GuestBook extends HttpServlet { private static final long serialVersionUID = 1L; public GuestBook() { super(); } public void init( ServletConfig config ) throws ServletException { super.init( config ); List entries = new ArrayList(); entries.add( new GuestBookEntry( 1, "john", "hello" ) ); entries.add( new GuestBookEntry( 2, "joe", "hi" ) ); getServletContext().setAttribute( "entries", entries ); } protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { request.getRequestDispatcher( "/WEB-INF/GuestBook.jsp" ) .forward( request, response ); } protected void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { doGet( request, response ); } }