package cs320.servlet; import java.io.IOException; import java.io.PrintWriter; 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("/Countdown") public class Countdown extends HttpServlet { private static final long serialVersionUID = 1L; int count = 10; protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { response.setContentType( "text/html" ); PrintWriter out = response.getWriter(); out.println( "" ); out.println( "Countdown" ); out.println( "" ); if( count > 0 ) { out.println( "

" + count + "

" ); --count; response.setHeader( "Refresh", "1" ); } else out.println( "

Rocket Launched!

" ); out.println( "" ); } protected void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { doGet( request, response ); } }