Off topic: Can Web Server retrieve JSPs from DB instead of filesystem?

Yes, this is a bit off topic, and I have received a comment about doing this in Tomcat, but wondered if any of the Java gurus who use and developed Vaadin had ever discovered if there’s a standard mechanism to have the JSP processor request the JSP source file through an adapter or servlet so that I could override it and provide the JSP file from our DB instead of writing them to the file system.

This would allow me to not have to worry about keeping my DB and the generated .jsp files in sync (like if someone blows away the generated code, or updates it directly instead of using our generated .jsp, etc.).


How JSPs are processed is roughly as follows (old approach, but I think the current engines do more or less the same):

  • The server receives a request for a JSP page and forwards it to the JSP engine.
  • JSP engine compiles the JSP page to a Java source file describing a servlet (if not already compiled).
  • The source generated in the previous step is compiled into a .class file (or a class in memory only).

The JSP engine monitors for changes in the JSP source, possibly checking files on the disk, and recompiles the servlet if necessary.

Therefore, you might need to look at the specific JSP engine in use (e.g. Jasper) and how it fetches the content. Note also that JSP pages often refer to other JSP pages, which can complicate the issue.