A start at refactoring AppServlet.java.