OK, that helps a little.
By default, .xhmtl is referred to XML. Unfortunately, we do not support embedded language modes in XML (since you could define any tag, not just script, or script could mean something completely different). Yes, XHTML, should be a special case, but that's not there yet. Anyway, this could be the case where you see the contents of the script colored as comments instead of as JavaScript. So please double check that you have xhtml referred to html.
You shouldn't see any problems with this in JSP, since that is by default treated as HTML. If you see a JSP that exhibits this problem, I suspect, I'm going to need a complete example in order to debug the problem.
By "sometimes they are colored", do you mean that in certain situations, the one script tag is color coded as comments and another is color coded as JavaScript, or that the *exact same* script will get color coded as comments one time you look at it and as JavaScript another time?