В моей заявке нет документов(pdf) по конкретному тендеру. Мне нужно создать zip-файл из этих pdf-файлов и разрешить пользователю загружать его.
Приложение выполнено в JavaEE с помощью struts и mysql. когда пользователь нажимает кнопку загрузки, вызывается этот класс действий. Код не дает никаких исключений, но и не предлагает пользователю что-либо скачать.
Помогите, пожалуйста, найти ошибку в коде.
Ниже приведен исходный код моего класса действий.
public class ActDownloadDocZip extends Action {
static Logger logger = Logger.getLogger(ActDownloadDocZip.class);
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String realPath = getServlet().getServletContext().getRealPath(
"/WEB-INF/log4jConfiguration.xml");
DOMConfigurator.configure(realPath);
logger.info("In ActDownloadDocZip....");
ActionForward forward = null;
HttpSession session = request.getSession();
// get a db connection
Connection conn = null;
String[][] nameFile = null;
String tenderNo = "";
try {
conn = ProxoolConnection.getProxoolConnectionSLT();
tenderNo = request.getParameter("tenderNo");
// File fileex=new File("xxx.zip");
FileOutputStream zipFile = new FileOutputStream(new File("xxx.zip"));
ZipOutputStream output = new ZipOutputStream(zipFile);
// call getPdfFiles method here
ILoadTenders ld = new LoadTenders();
nameFile = ld.getPdfFileListToTender(conn, tenderNo);//this method brings back the relevant pdf file names and paths((pdfname1,pdfpath1),(pdfname2,pdfpath2))
for (int i = 0; i < nameFile.length; i++) {
ZipEntry zipEntry = new ZipEntry(nameFile[i][0].trim());
output.putNextEntry(zipEntry);
FileInputStream pdfFile = new FileInputStream(new File(
nameFile[i][1].trim()));
IOUtils.copy(pdfFile, output);
pdfFile.close();
output.closeEntry();
}
output.finish();
output.close();
} catch (SQLException e) {
System.out.println("actDownloadDocZip " + e);
logger.fatal(e.getMessage());
} catch (Exception e) {
System.out.println("actDownloadDocZip1 " + e);
logger.fatal(e.getMessage());
} finally {
if (conn != null) {
ProxoolConnection.closeProxoolConnectionSLT(conn);
}
}
forward = mapping.findForward("publicdashboard");
return forward;
}
}