req.setAttribute("executors", executors);
// Action requested?
String action = req.getParameter("action");
if ("pause".equals(action)) {
String id = req.getParameter("id");
TaskExecutor executor = find(executors, id);
if (executor != null && executor.isAlive() && !executor.isStopped()
&& executor.canBePaused() && !executor.isPaused()) {
executor.pause();
}
} else if ("resume".equals(action)) {
String id = req.getParameter("id");
TaskExecutor executor = find(executors, id);
if (executor != null && executor.isAlive() && !executor.isStopped()
&& executor.canBePaused() && executor.isPaused()) {
executor.resume();
}
} else if ("stop".equals(action)) {
String id = req.getParameter("id");
TaskExecutor executor = find(executors, id);
if (executor != null && executor.isAlive()
&& executor.canBeStopped() && !executor.isStopped()) {
executor.stop();
}
}
// Layout.
String page = "/WEB-INF/ongoing.jsp";
RequestDispatcher dispatcher = req.getRequestDispatcher(page);