I\'ve seen this question regading the importing of js-files related to the tag content itself. I have a similar problem, here I have a jsp tag that generates some HTML and h
I'm not entirely sure what you asking here, but I don't there's anything wrong with including tags in the JSP to instantiate javascript code. I often follow this model, writing the library code in external javascript files, and then calling the constructors to my objects from the tags.
This makes debugging easy, since the logic is all in the external files (and firebug seems to have trouble with debugging inline javascript code). The libraries get cached, but the data instantiating them doesn't (which is the desired behavior).
The alternative is to have the instantiation code dynamically generated in an external javascript file or AJAX call. I've done this too, with positive results.
I think the deciding factor is how much dynamic data you have. If you need to represent large data structures, I would serve it out via an AJAX call that returns JSON. If its a simple call to a constructor, put it in the JSP.
As for the global variable, I will often have a global for the top-level object that kicks everything off. Inside that, are all the other references to the helper objects.