First thing : A pure JS code in a separate file will be cached, reducing the amount of data transfered on each request.
Unless you have a very small, page specific JS code, you shouldn't inline it.
Other valid reasons are already pointed in Mike's answer.
If you have to pass some values from the server to the JS, what you can do instead of injecting JSP code directly in your JS is to create a function in your external file, and call it from your page, passing your dynamic values as parameters :
JSP:
<script>
yourFunction(${param1}, ${param2}...);
</script>
JS external file:
function yourFunction (param1, param2...) {
// do your stuff
}
Or even better, especially if you have a large amount of variables, create an object to pass as a parameter instead of passing a bunch of params :
JSP:
<script>
var obj = {
param1: ${param1},
param2: ${param2}
...
}
yourFunction(obj)
</script>
JS external file:
function yourFunction (obj) {
// do your stuff using obj.param1, obj.param2...
}
When you are working on a code-base where you seriously consider this a good idea, it's a sign that you might be working with a horrible mess of spaghetti code.
In a well-organized codebase such tags should not be necessary, because each of these functionalities you mention should be contained in a single place. Components should be encapsulated and loosely coupled, so that you can change the way the path to some binary file is generated without having to change any other code.
Best Answer
Yes, but do make it obvious.
Do:
Don't: