Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ul> <li>use some preconfigured folder outside your webapp on the server. As it was mentioned earlier in the comments, it is not a good idea to generate them inside WEB-INF</li> <li>create servlet that will serve the content of the requested file to the user from your preconfigured folder</li> <li>you can also protect the servlet if it is needed</li> <li>the servlet can also delete the file as soon as it was delivered to the user</li> <li>alternatively, you can <a href="https://community.jboss.org/wiki/ExternalDirectories" rel="nofollow">map external folder</a> into webapp and let JBoss serve them as static content (but you need to protect the access if it is required)</li> </ul> <p>P.S. you may still do some "scheduled" cleanup in case the generated file is never downloaded.</p> <p><strong>Servlet serving the content</strong> (Answer to your comment)</p> <p>I do not see any problems with security when having external folder in your case. This external folder is only accessible in your application. </p> <p>Let's say you have a directory you generate files into (<em>FilesRootDir</em>) - /var/myapp/storage/tmp. </p> <ol> <li>Create the servlet in your webapp that knows the location of your <em>FilesRootDir</em></li> <li>Let's say the servlet is mapped to the following url (/mywebapp/downloads/file)</li> <li>To keep it simple your servlet receives as a parameter the relative path to the generated file (<em>path</em>) </li> <li>Taking the above <ol> <li>The app generates the file here /var/myapp/storage/tmp/dir1/document.csv</li> <li>and generates the link /mywebapp/downloads/file?path=/dir1/document.csv, so the user can download the file</li> </ol></li> <li>When the user decides to download the file, the request is handled by your servlet. <ol> <li>The servlet receives the location of the requested file - /dir1/document.csv</li> <li>constructs the absolute path concatenating <em>FilesRootDir</em> and <em>path parameter</em> - <em>/var/myapp/storage/tmp/dir1/document.csv</em></li> <li>Reads and outputs the content of the file to the user </li> </ol></li> </ol> <p>I believe you can apply the same security constraints to your servlet as you have it in your app, because it is a part of the application.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload