I have the following block of code in my bean class -
HttpServletResponse response = (HttpServletResponse) getFacesContext().getExternalContext().getResponse();
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
From my bean I call my service layer, which in turn calls the database layer, retrieves data and writes the files generated in a ZIP file in the service layer. I have an issue where I do not have a clue what to do if there are no files generated.
When I instantiate ZipOutputStream object in my bean, it creates a ZIP file and opens up a "Opening Extracts.zip" window, and when I click on OK, I get an error because there are no files in the ZIP folder.
Can somoone please tell me if there is any way I can move the zos instantiation to the service layer without having to pass the response object?
Thanks, Raaz