@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
SessionUtil sessionUtil = SessionUtil.getInstance();
ResultsTableGenerator tableGenerator = new ResultsTableGenerator();
tableGenerator.setSelectedContests(getSelectedContests(request, sessionUtil
.getContestManager().getContests()));
tableGenerator.setUserAccounts(sessionUtil.getUserAccountManager().getAllUsers());
tableGenerator.setIncludeTestGroupResults("group".equalsIgnoreCase(request
.getParameter("detail")));
tableGenerator.setGraderManager(sessionUtil.getGraderManager());
tableGenerator.setPersons(sessionUtil.getPersonManager().getAllPersons());
tableGenerator.createReportData();
if (Boolean.parseBoolean(request.getParameter("xls"))) {
response.setContentType("application/ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=\"results.xls\"");
ServletOutputStream out = response.getOutputStream();
HSSFWorkbook resultsxls = getTableAsXLS(tableGenerator.getResultsTable());
resultsxls.write(out);
} else {
request.setAttribute("table", tableGenerator.getResultsTable());
forwardAutoReload(request);
request.setAttribute("queryString", tableGenerator.getAutoReloadLink());
request.setAttribute("alternativeQuery", tableGenerator.getDetailsLink());
request.getRequestDispatcher("results_all.jsp").forward(request, response);
}
}