This week's book giveaway is in the Java in General forum. We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line! See this thread for details.
And the problem with externalizing the JS is you need access to those variables. Hidden fields are a good way of dealing with this. Also the metadata plugin for jQuery really helps. If you were to post a section of the code that is causing you issues with externalization we might be able to give you some tips on how to deal with it.
I'll let Bear address this with regards to his book.
But Gregg hit upon the key -- data (especially server-side data injected into the page via JSP -- EL, please avoid scriptlets) should be segregated from the code (rather than hard-coding) by tacking it onto the various elements.
The book examples do show this in action.
The meta-data capability is one way to do this, but I'm fond of using HTML5-style custom attributes (which can be used in HTML4 if you don't care about validators complaining) as they do not require extra code or plugins.