How to serve programmatically generated html pages on the file system in spring boot

265 Views Asked by At

I have a spring boot application that uses spring-web and embedded tomcat.

The app has a REST URI where a tar file will be posted to. The tar file will have a number of .csv files. The tar will be kept in a persistent data store for later retrieval.

When a user requests (using another REST API) to view the content of the tar, the application will

  1. fetch the relevant tar file from the database
  2. untar the relevant tar file into a randomly generated new directory inside system /tmp dir
  3. generate HTML pages (one for each csv) which has some bootstrap and other css involved for better UI look of the CSV data in tabular form
  4. and should be able to serve those pages.
  5. when the user logs off or after a certain time period of inactivity the randomly generated /tmp dir should be removed

Note that the additional requirement multiple users can access this server and upload/view different tar files at the same time and hence the need for creating a new temporary directory.

Questions:

  1. How to achieve the ability to serve dynamically generated HTML pages inside a random temp directory that is outside the scope of server's web-inf?
  2. Is it possible to achieve the same if I create temp directories inside the context path?
  3. How to achieve this for concurrent users trying to access different directories respectively?
  4. Are there any suggestions on a better way to design what I intend to do with the application here?
0

There are 0 best solutions below