Is it good practice to include <c: out> in an external javascript file?
We do a lot of JSP with jQuery / javascript to make the code more reusable, most of the javascript is thrown into an external library and then imported into the jsp file. However, inevitably some of the values ββto be used in javascript must be predefined by java / jsp, which means you will have cases like this
alert('<c:out value="${i18n_alert_msg}"');
I know that we can always supply parameters such as function parameters, but it can be very annoying when there are many such places, make the parameter list long and redundant.
So just wondering if this is good practice just leave <c:out/>
in the javascript file
source to share
no value "must be predefined". your js code can accept data from a request, a cookie, or, in the most flexible and powerful way, simply fetch it from the server.
you can create a fully dynamic single page application using only static resources so of course you don't need this feature. don't make js or css files dynamic - let clients cache them
source to share