@RequestMapping public void gen(GenCmd genCmd, HttpServletRequest request, HttpServletResponse response) throws Exception { String outputPath = outputRootDir + System.currentTimeMillis(); genCmd.setOutputRootDir(outputPath); genCmd.execute(); response.setHeader( "Content-Disposition", "attachment; filename=\"" + "generatorOutput.zip" + "\""); ZipHelper.zip(outputPath, response.getOutputStream()); }