But as you pointed out, this creates an issue because external script files aren't passed through the JSP translator. Generally, such close coupling between the server and the client is frowned upon, so it should be kept to the minimum. But sharing such things as constants between the client and the server is a useful way to make sure that they don't get out of sync.
This segregates the server<->client interaction to one place and completely frees all the rest of the script from reliance on the server and JSP translator.
Ketan Parikh wrote:You may consider Jsp fragments (.jspf). I used to modularize my larger Jsp file into set of .jspf files. As your code is divided into multiple fragments, it is easy to read and update it.