package cs320.servlet; import java.io.IOException; 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; @WebServlet("/ArrayServlet") public class ArrayServlet extends HttpServlet { private static final long serialVersionUID = 1L; public ArrayServlet() { super(); } public void init( ServletConfig config ) throws ServletException { super.init( config ); String array1[] = { "a", "b", "c" }; getServletContext().setAttribute( "array1", array1 ); } protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { String array2[] = { "one", "two", "three" }; request.setAttribute( "array2", array2 ); request.getRequestDispatcher( "/WEB-INF/array.jsp" ).forward( request, response ); } protected void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { doGet( request, response ); } }