0

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

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
  • Does this answer your question? [Simplest way to serve static data from outside the application server in a Java web application](https://stackoverflow.com/questions/1812244/simplest-way-to-serve-static-data-from-outside-the-application-server-in-a-java) (there's also no need to save the files statically, you can just stream a ZipOutputStream that you create at the time of the request. – Olaf Kock Nov 13 '21 at 07:53

0 Answers0