I have a web application in Java 8 deployed in an Apache Tomcat 9. I need that, when clicking on a button in a JSP, a folder with several PDFs is generated. This is compressed and then downloaded automatically. I get to the point of generating the .zip, but I don't know how to get it to download. I had thought of generating the .zip in the webapp folder or in a temporary folder that I can delete daily. Through AJAX, the request from the JSP and the servlet returns the URL, then use window.open (result.url, "_blank"); to generate the download. However, I don't know how to declare the path or the relative path in the class that generates and saves the .zip file.
The path I would like to get is something like
localhost:8080/myapp/tempfolder/my .zip file