What is the best way to allow both servlet and client scripts to read the same file?

We want to share the user validation configuration between the Java validation class (for health checks) and the web form interface with Javascript support (for ease of use). What is the best way to deploy this static file in our web application so that it can be accessed by server-side code and accessible through a URL that the client can access?

So far I have been thinking about putting the file in the root directory of the application and specifying the verification class on it when it is used, and putting the file in the WEB-INF / classes directory and somehow setting up the container to serve it.

Has anyone else set up such a web application? What did you end up doing?

+3
source share
1 answer

Yes. Put it in the WEB-INF / classes and set up the servlet for the corresponding part of the validation configurations based on something like a form identifier. Even better, the servlet will convert the configuration to a JSON object, and then you can just add a script tag and start using it :)

+3
source

Source: https://habr.com/ru/post/1699298/


All Articles