We do a lot of JSP with jQuery/javascript, to make the code more reusable, most of the javascript are thrown to an external library and then import to the jsp file. However, unavoidably some of the values to be used in javascript has to be predefined by java/jsp, that means there is going to have some cases like this
alert('<c:out value="${i18n_alert_msg}"');
I know we can always put such thing as parameters of the function, but it could be very nasty when there is a lot of places like this, make parameter list long and redundant.
So just wondering if it is a good practice just leave the <c:out/> in the javascript file
no value 'has to be predefined'. your js code can take data from request, cookies or, the most flexible and powerful way, simply fetch them from server.
you can build fully dynamic one-page-application using only static resources so for sure you don't need this feature. don't make js nor css files dynamic - let clients cache them
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With